You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Migrate menubar action registrations out of menubar.contribution.ts #54510
With the new menubar implementation, all menubar actions can be contributed via the MenuRegistry. Currently, all actions for the menubar are registered in a single file menubar.contribution.ts; however, it would be nice to have these registered and owned by the area owners from which they originate.
When moving your command registration to the appropriate location, you may also opt to add a precondition to the command so that it is enabled dynamically. I have chosen the debug actions as an example a08526a. Isidor Nikolic (@isidorn) I have not moved the registrations, only used them to demonstrate the use of precondition for the menu entries.
There is also a when clause on the menu entry that hides the entry if the condition is not met; however, we are not currently recommending this approach for the menubar unless you are swapping two entries that are mutually exclusive.
@Microsoft/vscode please review the menubar entries for ones that you can own and move the corresponding registration into a more appropriate location. You can then add a precondition if it applies. Please ping me if you have any questions.
Linking #991 which is the original issue. One thing to emphasize is that we should try hard to set a precondition on most menu items to make sure the enablement is proper. If a context key does not exist yet for a particular menu item, it should be added 👍
SteVen Batten (@sbatten) nice work.
I have moved the Debug menu contribution via 0738ae2 Benjamin Pasero (@bpasero) I can also move the View menu but not sure where to put it. How about it main.contribution? I can also create a new file view.contribution
SteVen Batten (@sbatten) the ugly part now is that we have double the registration both in menu.contribution.ts and in menus.ts. When will we be able to drop menus.ts and rely solely on the new way of registering menu items?
I have updated the checkboxes in the original comment such that we have some owners per menu item. Benjamin Pasero (@bpasero) I will move the file, view and window menus in appropriate places. Just do a code review once you are back SteVen Batten (@sbatten) please tryout my changes on windows. For window menu I will wait until this new way of registration is supported on the mac.
SteVen Batten (@sbatten) I tried to use precondition to control the enablement of Undo and Redo. One of the problems that came up is that the menubar menu entries are evaluated in the global context.
But in the workbench you can have multiple editors opened, some of which can undo and some of which cannot.
I have noticed that the menubar will refocus on the previously focused element when invoking the action, so if focus is in editor1, and then the Edit menu is opened, and Undo picked, focus is correctly brought back to editor1 before the command is invoked.
I think we could support high fidelity disablement/enablement of these commands if the menu items precondition would be evaluated in the context of the previous focused element. You can find the context associated with a particular element via IContextKeyService.getContext(previousFocusedElement).
Activity
bpasero commentedon Jul 18, 2018
Linking #991 which is the original issue. One thing to emphasize is that we should try hard to set a
preconditionon most menu items to make sure the enablement is proper. If a context key does not exist yet for a particular menu item, it should be added 👍Move terminal menu to parts/terminal
isidorn commentedon Jul 19, 2018
SteVen Batten (@sbatten) nice work.
I have moved the Debug menu contribution via 0738ae2
Benjamin Pasero (@bpasero) I can also move the View menu but not sure where to put it. How about it
main.contribution? I can also create a new fileview.contributionSteVen Batten (@sbatten) the ugly part now is that we have double the registration both in
menu.contribution.tsand inmenus.ts. When will we be able to dropmenus.tsand rely solely on the new way of registering menu items?menubar registration: file menu
isidorn commentedon Jul 19, 2018
I have updated the checkboxes in the original comment such that we have some owners per menu item.
Benjamin Pasero (@bpasero) I will move the file, view and window menus in appropriate places. Just do a code review once you are back
SteVen Batten (@sbatten) please tryout my changes on windows. For
windowmenu I will wait until this new way of registration is supported on the mac.menus: move View menu contributions to appropriate owners
menubar registration: appearance menu to appropriate owners
menubar registration: layout menu to appropriate owners
dbaeumer commentedon Jul 20, 2018
Done for tasks. Isidor Nikolic (@isidorn) thanks for your help.
Task part of #54510
Move Edit menu registrations next to the actions (#54510)
Wrap up menu bar registration migration (#54510)
alexdima commentedon Jul 25, 2018
SteVen Batten (@sbatten) I tried to use
preconditionto control the enablement of Undo and Redo. One of the problems that came up is that the menubar menu entries are evaluated in the global context.But in the workbench you can have multiple editors opened, some of which can undo and some of which cannot.
I have noticed that the menubar will refocus on the previously focused element when invoking the action, so if focus is in editor1, and then the Edit menu is opened, and Undo picked, focus is correctly brought back to editor1 before the command is invoked.
I think we could support high fidelity disablement/enablement of these commands if the menu items
preconditionwould be evaluated in the context of the previous focused element. You can find the context associated with a particular element viaIContextKeyService.getContext(previousFocusedElement).sandy081 commentedon Jul 25, 2018
Thanks Isidor Nikolic (@isidorn) for adopting
Open View...action.move help contributions to origins (for #54510)