diff --git a/src/vs/code/electron-main/menubar.ts b/src/vs/code/electron-main/menubar.ts index 469b2ab76ee..bd9aceb6879 100644 --- a/src/vs/code/electron-main/menubar.ts +++ b/src/vs/code/electron-main/menubar.ts @@ -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); } } diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index 21c79a07b8c..f0ba370d22d 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -98,7 +98,6 @@ export class MenuId { static readonly MenubarDebugMenu = new MenuId(); static readonly MenubarNewBreakpointMenu = new MenuId(); static readonly MenubarTasksMenu = new MenuId(); - static readonly MenubarWindowMenu = new MenuId(); static readonly MenubarPreferencesMenu = new MenuId(); static readonly MenubarHelpMenu = new MenuId(); static readonly MenubarTerminalMenu = new MenuId(); diff --git a/src/vs/workbench/browser/parts/menubar/menubarPart.ts b/src/vs/workbench/browser/parts/menubar/menubarPart.ts index 7bae0b21225..b0cbfbf570f 100644 --- a/src/vs/workbench/browser/parts/menubar/menubarPart.ts +++ b/src/vs/workbench/browser/parts/menubar/menubarPart.ts @@ -62,7 +62,7 @@ export class MenubarPart extends Part { 'workbench.statusBar.visible', 'workbench.activityBar.visible', 'window.enableMenuBarMnemonics', - // 'window.nativeTabs' + 'window.nativeTabs' ]; private topLevelMenus: { @@ -143,7 +143,6 @@ export class MenubarPart extends Part { if (isMacintosh) { this.topLevelMenus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService)); - this.topLevelMenus['Window'] = this._register(this.menuService.createMenu(MenuId.MenubarWindowMenu, this.contextKeyService)); } this.menuUpdater = this._register(new RunOnceScheduler(() => this.doSetupMenubar(), 100));