Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/vs/platform/menubar/electron-main/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,21 @@ export class Menubar extends Disposable {
return !!(event && ((!isMacintosh && (event.ctrlKey || event.shiftKey)) || (isMacintosh && (event.metaKey || event.altKey))));
}

private getCommandIdForClick(commandId: string, event: KeyboardEvent): string {
if (!this.isOptionClick(event)) {
return commandId;
}

switch (commandId) {
case 'workbench.action.files.openFileFolder':
return 'workbench.action.files.openFileFolderInNewWindow';
case 'workbench.action.files.openFolder':
return 'workbench.action.files.openFolderInNewWindow';
default:
return commandId;
Comment on lines +594 to +600
}
}

private isKeyboardEvent(event: KeyboardEvent): boolean {
return !!(event.triggeredByAccelerator || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey);
}
Expand Down Expand Up @@ -689,7 +704,7 @@ export class Menubar extends Disposable {
if (userSettingsLabel && event.triggeredByAccelerator) {
this.runActionInRenderer({ type: 'keybinding', userSettingsLabel });
} else {
this.runActionInRenderer({ type: 'commandId', commandId });
this.runActionInRenderer({ type: 'commandId', commandId: this.getCommandIdForClick(commandId, event) });
}
};
const enabled = typeof enabledOpt === 'boolean' ? enabledOpt : this.windowsMainService.getWindowCount() > 0;
Expand Down
27 changes: 25 additions & 2 deletions src/vs/workbench/browser/parts/titlebar/menubarControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { IMenuService, MenuId, IMenu, SubmenuItemAction, registerAction2, Action
import { MenuBarVisibility, IWindowOpenable, getMenuBarVisibility, MenuSettings, hasNativeMenu } from '../../../../platform/window/common/window.js';
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { IAction, Action, SubmenuAction, Separator, IActionRunner, ActionRunner, WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification, toAction } from '../../../../base/common/actions.js';
import { addDisposableListener, Dimension, EventType } from '../../../../base/browser/dom.js';
import { addDisposableListener, Dimension, EventType, isMouseEvent } from '../../../../base/browser/dom.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { isMacintosh, isWeb, isIOS, isNative } from '../../../../base/common/platform.js';
import { IConfigurationService, IConfigurationChangeEvent } from '../../../../platform/configuration/common/configuration.js';
Expand Down Expand Up @@ -377,6 +377,29 @@ export class CustomMenubarControl extends MenubarControl {
}
}

private isOptionClick(event: unknown): boolean {
if (!isMouseEvent(event)) {
return false;
}

return (!isMacintosh && (event.ctrlKey || event.shiftKey)) || (isMacintosh && (event.metaKey || event.altKey));
}

private getCommandIdForClick(commandId: string, event: unknown): string {
if (!this.isOptionClick(event)) {
return commandId;
}

switch (commandId) {
case 'workbench.action.files.openFileFolder':
return 'workbench.action.files.openFileFolderInNewWindow';
case 'workbench.action.files.openFolder':
return 'workbench.action.files.openFolderInNewWindow';
default:
return commandId;
Comment on lines +393 to +399
}
}

private getUpdateAction(): IAction | null {
const state = this.updateService.state;

Expand Down Expand Up @@ -578,7 +601,7 @@ export class CustomMenubarControl extends MenubarControl {
title = menuItem.item.toggled.mnemonicTitle ?? menuItem.item.toggled.title ?? title;
}

const newAction = store.add(new Action(menuItem.id, mnemonicMenuLabel(title), menuItem.class, menuItem.enabled, () => this.commandService.executeCommand(menuItem.id)));
const newAction = store.add(new Action(menuItem.id, mnemonicMenuLabel(title), menuItem.class, menuItem.enabled, event => this.commandService.executeCommand(this.getCommandIdForClick(menuItem.id, event))));
newAction.tooltip = menuItem.tooltip;
newAction.checked = menuItem.checked;
target.push(newAction);
Expand Down