Sublime Forum

How set the initial selection in a quick panel


Hi all!

I’m using show_quick_panel() from the sublime API (see the docs here).

I’m wondering if it’s possible to initially select one of the items other than the first one?

For instance, Goto Symbol (Ctrl/Cmd + R) doesn’t always start by selecting the first item, but selects the item that is nearest to the current location of the cursor. How would similar behaviour be implemented in a custom plugin?

PS: This post seems to have asked the same question without any answer (back in 2012!!).




IIRC the selected_index argument does that.

1 Like


So that was a bit daft of me!

Yes, that argument works well. Thanks!

For those that come here, @bschaaf is talking about <selected_index> in the signature below (taken from the documentation here.

show_quick_panel(items, on_done, <flags>, <selected_index>, <on_highlighted>, <placeholder>)

If I can defend myself a little, this argument isn’t mentioned in the description on the right even though every other argument is addressed. While selected_index is a fairly obvious name for this functionality, I had become accustomed to just scanning through the description and not looking at the signature.

It would probably be helpful to add a line to the description for the selected_text argument. Happy to make a pull request/issue if that helps.