Skip to content

Sub menus for Editor Context Menu #9827

Closed

Description

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

Activity

  1. added
    feature-request
    on Jul 27, 2016
  2. ungod commented on May 11, 2017

    @ungod
  3. TheMegaMatt commented on Aug 28, 2017

    @TheMegaMatt
  4. mike-lischke commented on Dec 22, 2017

    @mike-lischke

    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?

  5. added
    menus
    on Jan 5, 2018
  6. DanTup commented on Feb 12, 2018

    @DanTup
    Contributor

    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.

  7. jrieken commented on Feb 26, 2018

    @jrieken
    Contributor

    Danny Tuppeny (@DanTup) Regarding all those linked issues pointing towards more refactoring, please sync with Matt Bierner (@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

  8. DanTup commented on Feb 26, 2018

    @DanTup
    Contributor

    Johannes Rieken (@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?).

  9. mike-lischke commented on Feb 26, 2018

    @mike-lischke

    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.

  10. DanTup commented on Feb 26, 2018

    @DanTup
    Contributor

    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.

  11. jrieken commented on Feb 27, 2018

    @jrieken
    Contributor

    Yeah, this issue is about adding sub-menus but it seems that Danny Tuppeny (@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

  12. 3dots commented on Jan 3, 2019

    @3dots

    Hello. Has this FR petered out somewhat? Or does this have a chance of being put in?

    I just checked out a highlighting/marker extension, and figured: can't be that hard to make a context sub-menu which lets you toggle a highlight based on a list of colors already used in the file... Turns out it's not that simple after all.

    So, umm, does this mean you need to pipeline all that through the Lightbulb instead?

  13. 6 remaining items

  14. gjsjohnmurray commented on Jan 20, 2020

    @gjsjohnmurray
    Contributor

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

  15. damgot commented on Jan 31, 2020

    @damgot

    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

  16. viceice commented on Mar 4, 2020

    @viceice

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

  17. sentry07 commented on Apr 24, 2020

    @sentry07

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

  18. gjsjohnmurray commented on Apr 27, 2020

    @gjsjohnmurray
    Contributor

    Johannes Rieken (@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.

  19. Blaiski commented on May 13, 2020

    @Blaiski

    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? John Murray (@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

  20. zesluo commented on Aug 18, 2020

    @zesluo

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

  21. gjsjohnmurray commented on Aug 19, 2020

    @gjsjohnmurray
    Contributor

    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.

  22. zesluo commented on Aug 19, 2020

    @zesluo

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

  23. gjsjohnmurray commented on Aug 19, 2020

    @gjsjohnmurray
    Contributor

    Thanks for your reply! John Murray (@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.

  24. joaomoreno commented on Sep 1, 2020

    @joaomoreno
    Contributor

    Closing this, since it's done in master.

  25. locked and limited conversation to collaborators on Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apifeature-requestmenus

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions