Path: blob/main/src/vs/workbench/contrib/codeEditor/electron-browser/inputClipboardActions.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { KeybindingsRegistry } from '../../../../platform/keybinding/common/keybindingsRegistry.js';6import * as platform from '../../../../base/common/platform.js';7import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';8import { getActiveWindow } from '../../../../base/browser/dom.js';910if (platform.isMacintosh) {1112// On the mac, cmd+x, cmd+c and cmd+v do not result in cut / copy / paste13// We therefore add a basic keybinding rule that invokes document.execCommand14// This is to cover <input>s...1516KeybindingsRegistry.registerCommandAndKeybindingRule({17id: 'execCut',18primary: KeyMod.CtrlCmd | KeyCode.KeyX,19handler: bindExecuteCommand('cut'),20weight: 0,21when: undefined,22});23KeybindingsRegistry.registerCommandAndKeybindingRule({24id: 'execCopy',25primary: KeyMod.CtrlCmd | KeyCode.KeyC,26handler: bindExecuteCommand('copy'),27weight: 0,28when: undefined,29});30KeybindingsRegistry.registerCommandAndKeybindingRule({31id: 'execPaste',32primary: KeyMod.CtrlCmd | KeyCode.KeyV,33handler: bindExecuteCommand('paste'),34weight: 0,35when: undefined,36});3738function bindExecuteCommand(command: 'cut' | 'copy' | 'paste') {39return () => {40getActiveWindow().document.execCommand(command);41};42}43}444546