diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts index 822ef79826190e2fc4a6816bca621bf0ac38610e..90406fa348325f978bb9234d1049d35fdb221d17 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminal.contribution.ts @@ -120,6 +120,11 @@ configurationRegistry.registerConfiguration({ 'type': 'boolean', 'default': TERMINAL_DEFAULT_RIGHT_CLICK_COPY_PASTE }, + 'terminal.integrated.copyOnSelection': { + 'description': nls.localize('terminal.integrated.copyOnSelection', "When set, text selected in the terminal will be copied to the clipboard."), + 'type': 'boolean', + 'default': false + }, 'terminal.integrated.fontFamily': { 'description': nls.localize('terminal.integrated.fontFamily', "Controls the font family of the terminal, this defaults to editor.fontFamily's value."), 'type': 'string' diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts index 626397cd57bd91e988617482b2d9cadb25535c4d..d12de43f06d3bde246abfd5b1c305b34fc1e43eb 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts @@ -222,6 +222,20 @@ export class TerminalPanel extends Panel { } } })); + this._register(dom.addDisposableListener(this._parentDomElement, 'mouseup', (event: MouseEvent) => { + if (this._configurationService.getValue('terminal.integrated.copyOnSelection')) { + if (this._terminalService.terminalInstances.length === 0) { + return; + } + + if (event.which === 1) { + let terminal = this._terminalService.getActiveInstance(); + if (terminal.hasSelection()) { + terminal.copySelection(); + } + } + } + })); this._register(dom.addDisposableListener(this._parentDomElement, 'contextmenu', (event: MouseEvent) => { if (!this._cancelContextMenu) { const standardEvent = new StandardMouseEvent(event);