sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

ADD_TO_SELECTION flag is ignored for Window.new_html_sheet API

Open jwortmann opened this issue 2 years ago • 4 comments

Description of the bug

According to the API documentation, sublime.ADD_TO_SELECTION is a valid flag for Window.new_html_sheet(), but it doesn't work.

Steps to reproduce

  1. Start ST in safe mode.
  2. Open a new tab (Ctrl+N).
  3. Open the console and paste
    window.new_html_sheet("My HtmlSheet", "", flags=sublime.ADD_TO_SELECTION)
    

Expected behavior

Both tabs are selected (side-by-side mode), similar to how it works for

window.open_file("D:\\some\\filepath.txt", flags=sublime.ADD_TO_SELECTION)

Actual behavior

Only the new HtmlSheet is selected.

Sublime Text build number

4126

Operating system & version

Windows 11

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

jwortmann avatar Jul 04 '22 14:07 jwortmann

New views are also not added to selection.

window.new_file(flags=sublime.ADD_TO_SELECTION)

deathaxe avatar Jul 04 '22 16:07 deathaxe

New views are also not added to selection.

That is correct, but it also complies with the documentation, because ADD_TO_SELECTION is not listed as possible flag for new_file (only TRANSIENT is allowed here).

Whereas the documentation for new_html_sheet explicitly lists ADD_TO_SELECTION as a valid flag.

jwortmann avatar Jul 04 '22 16:07 jwortmann

I'd just expect all of them to behave equally. A plugin might also want to add a new view next to the current one and add some output afterwards.

deathaxe avatar Jul 04 '22 16:07 deathaxe

Yes, I agree.

Currently we could use the following workaround:

selected_sheets = window.selected_sheets()
new_sheet = window.new_html_sheet("My HtmlSheet", "")  # or   new_sheet = window.new_file().sheet()
selected_sheets.append(new_sheet)
window.select_sheets(selected_sheets)

jwortmann avatar Jul 04 '22 16:07 jwortmann

Fixed in build 4135.

BenjaminSchaaf avatar Sep 15 '22 06:09 BenjaminSchaaf