-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Remove the old menu implementation #54826
Conversation
@sbatten thanks for the PR. Before I test the new branch could you clarify something:
I can test this in great detail, but for the review I only did a birds eye perspective review (comments lnline). @bpasero would be better for the more detailed review (if needed next week once he comes back from vacation) |
src/vs/code/electron-main/menubar.ts
Outdated
@@ -70,7 +57,8 @@ export class Menubar { | |||
// this.nativeTabMenuItems = []; | |||
|
|||
this.menuUpdater = new RunOnceScheduler(() => this.doUpdateMenu(), 0); | |||
this.keybindingsResolver = instantiationService.createInstance(KeybindingsResolver); | |||
// this.keybindingsResolver = instantiationService.createInstance(KeybindingsResolver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented line still needed, same for line 104
@@ -277,6 +252,15 @@ export class Menubar { | |||
menubar.append(gotoMenuItem); | |||
} | |||
|
|||
// Terminal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not feel right that this component is aware of the terminal menu.
Couldn't this be done fully from the terminal.contribution? What is missing for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you specifically mean for terminal, tasks and preferences? or are you referring to every top-level menu?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the nicest would be that every top level menu item is registered outside and that we do not reference them manually here
@@ -290,8 +274,8 @@ export class Menubar { | |||
const taskMenu = new Menu(); | |||
const taskMenuItem = new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'mTask', comment: ['&& denotes a mnemonic'] }, "&&Tasks")), submenu: taskMenu }); | |||
|
|||
if (this.shouldDrawMenu('Task')) { | |||
this.setMenuById(taskMenu, 'Task'); | |||
if (this.shouldDrawMenu('Tasks')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for Terminal
above.
Also for Preferences
below.
this.setMenu(submenu, item.submenu.items); | ||
menu.append(submenuItem); | ||
} else if (isMenubarMenuItemAction(item)) { | ||
if (item.id === 'workbench.action.openRecent') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave a TODO here since it feels a bit hacky how we are inserting recent menu items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, we do this on both sides for the custom and native menubar experience. maybe we should discuss with a joh a way to do this better with the MenuRegistry in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you like me to create a debt item so we do not forget about this
fyi @jrieken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's that about? dynamically computed menu entries?
src/vs/code/electron-main/menubar.ts
Outdated
private nativeTabMenuItems: Electron.MenuItem[]; | ||
|
||
private menubarMenus: IMenubarData = {}; | ||
|
||
private keybindings: { [commandId: string]: IKeybinding }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use a Map<string, IKeybinding>
src/vs/code/electron-main/menubar.ts
Outdated
this.setMenu(menu, this.menubarMenus[menuId].items); | ||
} | ||
|
||
private insertRecentMenuItems(menu: Electron.Menu) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like it deos not belong in this file. this hsould be contributed by the filesActions.contributions imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above?
export interface IMenubarKeybinding { | ||
id: string; | ||
label: string; | ||
isNative: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is isNative
read and what is the purpose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used in menubar.ts
under electron-main
. I was accidentally using IKeybinding
still in that file which is now fixed so it should be easier to find.
if (isMacintosh && isWindows) { | ||
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus()); | ||
} | ||
this.menubarService.updateMenubar(this.windowService.getCurrentWindowId(), this.getMenubarMenus()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not really see a point of a private method called just once that has a one line call. Just my 2 cents from the birds eye perspective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason is primarily for symmetry. Where this is called we call either custom or native and the custom one is super long. I could make less functions and more if statements to achieve the same level of readability or just add a comment and remove the private function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever you prefer :)
}, | ||
order: 1 | ||
}); | ||
if (!isMacintosh) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use when
clauses instead of the ugly if
brackets,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to do that. I tried but I didn't see platform context keys, but I may have missed them. Are you aware?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In response to your initial comment: I will remove the |
@sbatten great, just ping me once all those files are removed and I will test this out on mac. |
Thinking about going forward and what we do for this milestone my recommendation is to have some setting for windows, like This flag does not have to be a part of this PR but something to keep in mind. Also let me know if I can help in any way. |
@isidorn fixed issues, please merge if ok, thanks for the review |
Looks great, nice work! I have resolved some conflicts and am merging. |
This removes the old menubar implementation to allow macOS and the native menubar experience to take advantage of the new menubar registration. Please test the new branch and review.