-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow extensions to contribute dynamic submenus #110218
Comments
Also pinging @Blaiski @larshp @gautier-lefebvre @erythana @yubaoquan @joaomoreno in case you want to 👍 this issue to try and get it into Backlog. Remember, do that on the original issue above, not on this comment. |
Is this the same as #27536? There are definitely many places I'd like dynamic menus (though not just sub-menus - for example on custom tree nodes). One argument against them in the past was making context menus slow (by doing async work), though I think in all my cases I could provide the commands up-front, just not statically (for example at the time I provide a tree node). |
Another +1 from me too. I need to contribute dynamic submenus include menu title according to my setting.json in VS Code |
I have a scenario of adding a submenu to a tree view item. |
@gjsjohnmurray are there any news on this? |
@MaxKless I am not aware of any news. I am a contributor but not a member of the core team, but my hunch is they would want to do this themselves if it ever happens. |
This comment was marked as off-topic.
This comment was marked as off-topic.
The current |
Currently an extension's menu and submenu contributions can only be statically defined in its package.json. At runtime the extension can use context keys it creates via the
setContext
command together withwhen
clauses to hide its contributed items dynamically. But there are use-cases where the actual items cannot be predefined, and we have to resort to a QuickPick. IMO this results in a poor UX and some accessibility issues because the list of choices does not appear alongside the context menu action which triggered it.I see two ways of solving this.
A) Allow submenu contents to be computed when the parent menu entry is selected (or perhaps merely focused).
I outlined this in #9827 (comment)
B) Add a
setSubmenuContents
equivalent to the existingsetContext
command.Using this approach an extension would run the new command, specifying the id of one of the submenus it had defined in its settings.json, plus a second command argument containing the new definition of the submenu.
The text was updated successfully, but these errors were encountered: