Core commands browser shows docs (and copies signature) of the wrong command when filter_core_commands_on_type is set
When filter_core_commands_on_type is set to anything other than all four types, the core-commands browser shows the documentation (and copies the signature) of the wrong command: the quick panel is built from the filtered commands, but on_select / on_highlight use the selected index against the unfiltered command list.
Cause (src/commands/commands_browser_core_commands.py):
run()skips commands whose type is not in the filter (if value["command_type"] not in cmd_type_filter_list: continue) and appends the rest toitems, so panel indexirefers to the i-th filtered item.- but the callbacks are given the full, unfiltered data:
and both useon_select = lambda idx, event: self.on_select(idx, event, commands_data.items()), on_highlight = lambda idx: self.on_highlight(idx, commands_data.items()),list(commands_data)[idx]on it. So indexipicks the i-th command of the whole dict.
Steps to reproduce (Sublime Text 4215, Windows, CommandsBrowser 1.x from Package Control):
- In the CommandsBrowser settings set
"filter_core_commands_on_type": ["window"]. - Run
CommandsBrowser: Browse available Sublime Text core commands.(the panel now lists 136 window commands:auto_complete_goto_definition,build,cancel_build, ...). - Choose an entry.
Actual (I selected items 0, 1 and 2 programmatically through the quick-panel callback; only the UI call was replaced):
picked item auto_complete_goto_definition -> doc panel shows: Name of the command: add_directory
picked item build -> doc panel shows: Name of the command: add_word
picked item cancel_build -> doc panel shows: Name of the command: add_where_snippet
With the default (all types) the lists are identical, so it only shows up when a type filter is active. Holding the copy-signature modifier while choosing an item copies the signature of the wrong command as well, because it uses the same list(commands_data)[idx]. The same applies to on_highlight (auto-open documentation panel).
Expected: the documentation for the command that was highlighted or chosen.
Suggested fix: build a list of the filtered (name, data) pairs in run() and pass that list (not commands_data.items()) to the callbacks.
Additional confirmation with the real UI (no test harness): with "filter_core_commands_on_type": ["window"] I ran CommandsBrowser: Browse available Sublime Text core commands. (the panel showed "Browse through 136 available Sublime Text commands ..." with auto_complete_goto_definition highlighted) and pressed Enter on that first item. The documentation panel that opened says:
Name of the command: add_directory
Description: Opens an OS dialog box to prompt for a folder to the 'Where' field in the 'Find in Files' panel.
i.e. the docs of add_directory, the first command in the unfiltered list, not of the command that was selected. Sublime Text 4215, Windows.