mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 06:51:53 +01:00
macOS: Cmd+A does not work in native parts (dialogs, search) (fixes #19003)
This commit is contained in:
@@ -49,6 +49,11 @@ interface IConfiguration extends IFilesConfiguration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IMenuItemClickHandler {
|
||||||
|
inDevTools: (contents: Electron.WebContents) => void;
|
||||||
|
inNoWindow: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
const telemetryFrom = 'menu';
|
const telemetryFrom = 'menu';
|
||||||
|
|
||||||
export class CodeMenu {
|
export class CodeMenu {
|
||||||
@@ -539,8 +544,14 @@ export class CodeMenu {
|
|||||||
let paste: Electron.MenuItem;
|
let paste: Electron.MenuItem;
|
||||||
|
|
||||||
if (isMacintosh) {
|
if (isMacintosh) {
|
||||||
undo = this.createDevToolsAwareMenuItem(nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo"), 'undo', devTools => devTools.undo());
|
undo = this.createContextAwareMenuItem(nls.localize({ key: 'miUndo', comment: ['&& denotes a mnemonic'] }, "&&Undo"), 'undo', {
|
||||||
redo = this.createDevToolsAwareMenuItem(nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo"), 'redo', devTools => devTools.redo());
|
inDevTools: devTools => devTools.undo(),
|
||||||
|
inNoWindow: () => Menu.sendActionToFirstResponder('undo:')
|
||||||
|
});
|
||||||
|
redo = this.createContextAwareMenuItem(nls.localize({ key: 'miRedo', comment: ['&& denotes a mnemonic'] }, "&&Redo"), 'redo', {
|
||||||
|
inDevTools: devTools => devTools.redo(),
|
||||||
|
inNoWindow: () => Menu.sendActionToFirstResponder('redo:')
|
||||||
|
});
|
||||||
cut = this.createRoleMenuItem(nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t"), 'editor.action.clipboardCutAction', 'cut');
|
cut = this.createRoleMenuItem(nls.localize({ key: 'miCut', comment: ['&& denotes a mnemonic'] }, "Cu&&t"), 'editor.action.clipboardCutAction', 'cut');
|
||||||
copy = this.createRoleMenuItem(nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy"), 'editor.action.clipboardCopyAction', 'copy');
|
copy = this.createRoleMenuItem(nls.localize({ key: 'miCopy', comment: ['&& denotes a mnemonic'] }, "&&Copy"), 'editor.action.clipboardCopyAction', 'copy');
|
||||||
paste = this.createRoleMenuItem(nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste"), 'editor.action.clipboardPasteAction', 'paste');
|
paste = this.createRoleMenuItem(nls.localize({ key: 'miPaste', comment: ['&& denotes a mnemonic'] }, "&&Paste"), 'editor.action.clipboardPasteAction', 'paste');
|
||||||
@@ -611,7 +622,10 @@ export class CodeMenu {
|
|||||||
|
|
||||||
let selectAll: Electron.MenuItem;
|
let selectAll: Electron.MenuItem;
|
||||||
if (isMacintosh) {
|
if (isMacintosh) {
|
||||||
selectAll = this.createDevToolsAwareMenuItem(nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All"), 'editor.action.selectAll', (devTools) => devTools.selectAll());
|
selectAll = this.createContextAwareMenuItem(nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All"), 'editor.action.selectAll', {
|
||||||
|
inDevTools: devTools => devTools.selectAll(),
|
||||||
|
inNoWindow: () => Menu.sendActionToFirstResponder('selectAll:')
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
selectAll = this.createMenuItem(nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All"), 'editor.action.selectAll');
|
selectAll = this.createMenuItem(nls.localize({ key: 'miSelectAll', comment: ['&& denotes a mnemonic'] }, "&&Select All"), 'editor.action.selectAll');
|
||||||
}
|
}
|
||||||
@@ -1084,21 +1098,25 @@ export class CodeMenu {
|
|||||||
return new MenuItem(this.withKeybinding(commandId, options));
|
return new MenuItem(this.withKeybinding(commandId, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDevToolsAwareMenuItem(label: string, commandId: string, devToolsFocusedFn: (contents: Electron.WebContents) => void): Electron.MenuItem {
|
private createContextAwareMenuItem(label: string, commandId: string, clickHandler: IMenuItemClickHandler): Electron.MenuItem {
|
||||||
return new MenuItem(this.withKeybinding(commandId, {
|
return new MenuItem(this.withKeybinding(commandId, {
|
||||||
label: this.mnemonicLabel(label),
|
label: this.mnemonicLabel(label),
|
||||||
enabled: this.windowsService.getWindowCount() > 0,
|
enabled: this.windowsService.getWindowCount() > 0,
|
||||||
click: () => {
|
click: () => {
|
||||||
const windowInFocus = this.windowsService.getFocusedWindow();
|
|
||||||
if (!windowInFocus) {
|
// No Active Window
|
||||||
return;
|
const activeWindow = this.windowsService.getFocusedWindow();
|
||||||
|
if (!activeWindow) {
|
||||||
|
return clickHandler.inNoWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (windowInFocus.win.webContents.isDevToolsFocused()) {
|
// DevTools focused
|
||||||
devToolsFocusedFn(windowInFocus.win.webContents.devToolsWebContents);
|
if (activeWindow.win.webContents.isDevToolsFocused()) {
|
||||||
} else {
|
return clickHandler.inDevTools(activeWindow.win.webContents.devToolsWebContents);
|
||||||
this.windowsService.sendToFocused('vscode:runAction', commandId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally execute command in Window
|
||||||
|
this.windowsService.sendToFocused('vscode:runAction', commandId);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user