Skip to content
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

Sub menus for Editor Context Menu #9827

Closed
DonJayamanne opened this issue Jul 27, 2016 · 26 comments
Closed

Sub menus for Editor Context Menu #9827

DonJayamanne opened this issue Jul 27, 2016 · 26 comments
Assignees
Milestone

Comments

@DonJayamanne
Copy link
Contributor

@DonJayamanne DonJayamanne commented Jul 27, 2016

Can we have the ability to define sub menus for editor context menus (possibly to the editor/title men too).
For instance when adding menu items for refactoring there could be plenty of refactoring items:

  • Extract variable
  • Extract method
  • Extract constant
  • Rename
  • Move class
  • Change signature... etc

I believe adding all of them to the context menu without adding them as sub menus could result in a cluttered UX.

sample

sample2

@ungod

This comment was marked as spam.

@TheMegaMatt

This comment was marked as spam.

@mike-lischke
Copy link

@mike-lischke mike-lischke commented Dec 22, 2017

May I asked about the current status of this FR? Given that we have this patch since more than a year, I wonder when we can actually use submenus in our extensions?

@jrieken jrieken added the menus label Jan 5, 2018
@DanTup
Copy link
Contributor

@DanTup DanTup commented Feb 12, 2018

As well as being able to add items to a sub-menu, we should be able to do this dynamically (eg. with a request to a provider, not just declarative) so that we can disable/hide refactors that are not applicable to the current position/selection.

@jrieken
Copy link
Member

@jrieken jrieken commented Feb 26, 2018

@DanTup Regarding all those linked issues pointing towards more refactoring, please sync with @mjbvz and me about our new code action types. Idea is that you predefine certain code action types, e.g. this is about extracting and we then populate the light bulb and a (new) refactorings menu for you. See https://code.visualstudio.com/updates/v1_20#_codeactionprovider-improvements

@DanTup
Copy link
Contributor

@DanTup DanTup commented Feb 26, 2018

@jrieken Yeah, I've somewhat changed my mind a little since the last comment. I thought we had a lot of refactors that are available "for the whole file" and would result in lightbulbs no matter where the cursor is; however there actually seem to be very few.

So for now, this isn't a big deal to me - however the idea of adding things like refactors/light bulbs to context menu has come up several times in discussions about visibility. I have noticed that the lightbulb sometimes doesn't seem very noticeable hovering over code (did it used to be in the gutter?).

@mike-lischke
Copy link

@mike-lischke mike-lischke commented Feb 26, 2018

Hmm, is this FR about a different way to add refactoring support or a general FR for submenus? I had the impression, it's the latter. I need a sub menu for various actions my extension can do for a (grammar) file, like showing some graphs, profiling details etc. This is not related to refactoring and hence cannot (and should not) be covered by the light bulb menu.

@DanTup
Copy link
Contributor

@DanTup DanTup commented Feb 26, 2018

I think it was a general request for context menus; which I requested can be contributed dynamically (eg. not declarative, so we can handle a request for a context menu and choose what to put in there asynchronously), but possibly I also derailed a little about having lightbulbs shown in there too.

@jrieken
Copy link
Member

@jrieken jrieken commented Feb 27, 2018

Yeah, this issue is about adding sub-menus but it seems that @DanTup implements various refactoring commands and those we wouldn't like to see as separate commands but to integrate into the platform - it's similar to us not liking separate format or rename commands. However, for code actions (refactorings & quick fixes) it's more fuzzy and that's why we have the new API in place

@phiter
Copy link

@phiter phiter commented Jun 25, 2019

updates on this? I wish I could create an extension to create new file from a template like they do in PHPStorm

@rockxsj

This comment was marked as spam.

@swjain23
Copy link

@swjain23 swjain23 commented Dec 11, 2019

Any update on this? We want to group commands to support adding new files from template, like in Visual Studio:

image

@ghost
Copy link

@ghost ghost commented Jan 20, 2020

Do we have this already? Because I'm seeing this:

image

V1.41.1

@gjsjohnmurray
Copy link
Contributor

@gjsjohnmurray gjsjohnmurray commented Jan 20, 2020

AFAIK it's not yet possible for extensions to contribute submenus. See #85218 (comment) for my hope that it'll come soon.

@damgot
Copy link

@damgot damgot commented Jan 31, 2020

I'm also interested on it.
I've so many command in my extension's editor context menu... I really need to be able to arrange them in sub-menus

@viceice
Copy link

@viceice viceice commented Mar 4, 2020

We love to see that too. Want to use it in the standalone monaco editor.

@sentry07
Copy link

@sentry07 sentry07 commented Apr 24, 2020

Another +1 from me. Grouping editor/context commands into sub menus would be amazing to have.

@gjsjohnmurray
Copy link
Contributor

@gjsjohnmurray gjsjohnmurray commented Apr 27, 2020

@jrieken until now you have (understandably) resisted requests for extensions to be able to contribute menu items that get computed dynamically (i.e. at the point where the context menu is about to be displayed).

Would you consider permitting this for submenus, when (as many of us hope) it becomes possible for an extension to contribute submenus?

For instance, my extension might add an "Extra Stuff" submenu entry to the editor/context menu in such a way that when the context menu appears it shows Extra Stuff > and invokes an async function in my extension to return the computed contents of my submenu. A cancellation token would allow the menu handler to cancel my compute if the user dismissed the first-level menu before I had supplied the submenu contents. And if the user's interaction with the context menu requests display of the submenu before the async function has completed, maybe show a spinner in place of the > on the menu entry.

@Blaiski
Copy link

@Blaiski Blaiski commented May 13, 2020

Another +1 from me too. It's been four years since this feature has been requested. Is there any hope we might be getting it soon, please? Anyone who can see that it's just impractical to expect extensions to keep adding their menu items all at the top level? @gjsjohnmurray I also add my voice here. I need to compute and generate my submenus dynamically so I'd expect to be able to do them using async functions just like the case with showQuickPick

Thank you

@zesluo
Copy link

@zesluo zesluo commented Aug 18, 2020

just wondering, is it available now for adding submenu to context menu? Thanks

@gjsjohnmurray
Copy link
Contributor

@gjsjohnmurray gjsjohnmurray commented Aug 19, 2020

just wondering, is it available now for adding submenu to context menu? Thanks

Now available in Insiders as a proposed API, slated for finalization in in the next-but-one release.

@zesluo
Copy link

@zesluo zesluo commented Aug 19, 2020

Thanks for your reply! @gjsjohnmurray , May I know when it will be public?

@gjsjohnmurray
Copy link
Contributor

@gjsjohnmurray gjsjohnmurray commented Aug 19, 2020

Thanks for your reply! @gjsjohnmurray , May I know when it will be public?

The related issue (#100172) Is currently showing as on the September 2020 milestone, meaning it's slated to ship in Stable in early October.

@joaomoreno
Copy link
Member

@joaomoreno joaomoreno commented Sep 1, 2020

Closing this, since it's done in master.

@joaomoreno joaomoreno closed this Sep 1, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet