mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
don't display fallback menu unless we've closed the last window
This commit is contained in:
@@ -31,12 +31,13 @@ export class Menubar {
|
||||
private static readonly MAX_MENU_RECENT_ENTRIES = 10;
|
||||
private isQuitting: boolean;
|
||||
private appMenuInstalled: boolean;
|
||||
private closedLastWindow: boolean;
|
||||
|
||||
private menuUpdater: RunOnceScheduler;
|
||||
|
||||
private nativeTabMenuItems: Electron.MenuItem[];
|
||||
|
||||
private menubarMenus: IMenubarData = {};
|
||||
private menubarMenus: IMenubarData;
|
||||
|
||||
private keybindings: { [commandId: string]: IMenubarKeybinding };
|
||||
|
||||
@@ -54,6 +55,8 @@ export class Menubar {
|
||||
|
||||
this.keybindings = Object.create(null);
|
||||
|
||||
this.closedLastWindow = false;
|
||||
|
||||
this.install();
|
||||
|
||||
this.registerListeners();
|
||||
@@ -149,9 +152,9 @@ export class Menubar {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Update menu if window count goes from N > 0 or 0 > N to update menu item enablement
|
||||
if ((e.oldCount === 0 && e.newCount > 0) || (e.oldCount > 0 && e.newCount === 0)) {
|
||||
this.closedLastWindow = e.newCount === 0;
|
||||
this.scheduleUpdateMenu();
|
||||
}
|
||||
|
||||
@@ -379,18 +382,22 @@ export class Menubar {
|
||||
|
||||
switch (menuId) {
|
||||
case 'File':
|
||||
case 'Window':
|
||||
case 'Help':
|
||||
if (isMacintosh) {
|
||||
return this.windowsMainService.getWindowCount() === 0 || !!this.menubarMenus[menuId];
|
||||
return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (!!this.menubarMenus && !!this.menubarMenus[menuId]);
|
||||
}
|
||||
break;
|
||||
case 'Window':
|
||||
if (isMacintosh) {
|
||||
return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || !!this.menubarMenus;
|
||||
}
|
||||
default:
|
||||
return this.windowsMainService.getWindowCount() > 0 && !!this.menubarMenus[menuId];
|
||||
return this.windowsMainService.getWindowCount() > 0 && (!!this.menubarMenus && !!this.menubarMenus[menuId]);
|
||||
}
|
||||
}
|
||||
|
||||
private shouldFallback(menuId: string): boolean {
|
||||
return this.shouldDrawMenu(menuId) && (this.windowsMainService.getWindowCount() === 0 && isMacintosh);
|
||||
return this.shouldDrawMenu(menuId) && (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow && isMacintosh);
|
||||
}
|
||||
|
||||
private setFallbackMenuById(menu: Electron.Menu, menuId: string): void {
|
||||
@@ -520,7 +527,7 @@ export class Menubar {
|
||||
}
|
||||
|
||||
private setMenuById(menu: Electron.Menu, menuId: string): void {
|
||||
if (this.menubarMenus[menuId]) {
|
||||
if (this.menubarMenus && this.menubarMenus[menuId]) {
|
||||
this.setMenu(menu, this.menubarMenus[menuId].items);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user