sublime_text
sublime_text copied to clipboard
ADD_TO_SELECTION flag is ignored for Window.new_html_sheet API
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
- Start ST in safe mode.
- Open a new tab (Ctrl+N).
- 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
New views are also not added to selection.
window.new_file(flags=sublime.ADD_TO_SELECTION)
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.
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.
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)
Fixed in build 4135.