diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts index 317e04be7015c00d1b4c435c4c7340671597724e..04febdfbe70ab21822cd998d527025bd0295a9d4 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts @@ -332,18 +332,15 @@ export class TerminalInstance implements ITerminalInstance { return undefined; }); this._instanceDisposables.push(dom.addDisposableListener(this._xterm.element, 'mousedown', (event: KeyboardEvent) => { - // We need to listen to the mouseup event up to the document since the user may release the mouse button anywhere - // outside of _xterm.element. + // We need to listen to the mouseup event on the document since the user may release + // the mouse button anywhere outside of _xterm.element. const listener = dom.addDisposableListener(document, 'mouseup', (event: KeyboardEvent) => { + // Delay with a setTimeout to allow the mouseup to propagate through the DOM + // before evaluating the new selection state. setTimeout(() => this._refreshSelectionContextKey(), 0); listener.dispose(); }); })); - this._instanceDisposables.push(dom.addDisposableListener(this._xterm.element, 'mouseup', (event: KeyboardEvent) => { - // Wait until mouseup has propagated through the DOM before - // evaluating the new selection state. - setTimeout(() => this._refreshSelectionContextKey(), 0); - })); // xterm.js currently drops selection on keyup as we need to handle this case. this._instanceDisposables.push(dom.addDisposableListener(this._xterm.element, 'keyup', (event: KeyboardEvent) => {