From d81df46453637efa0bd979f992454febb3e01ff2 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 27 Oct 2017 16:48:00 -0700 Subject: [PATCH] Don't send mouse events when selection is forced Fixes #1090 --- src/SelectionManager.ts | 13 ++++++++++--- src/Terminal.ts | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index 5dd652e0..4f50d35a 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -307,6 +307,15 @@ export class SelectionManager extends EventEmitter implements ISelectionManager return (offset / Math.abs(offset)) + Math.round(offset * (DRAG_SCROLL_MAX_SPEED - 1)); } + /** + * Returns whether the selection manager should force selection, regardless of + * whether the terminal is in mouse events mode. + * @param event The mouse event. + */ + public shouldForceSelection(event: MouseEvent): boolean { + return Browser.isMac ? event.altKey : event.shiftKey; + } + /** * Handles te mousedown event, setting up for a new selection. * @param event The mousedown event. @@ -325,9 +334,7 @@ export class SelectionManager extends EventEmitter implements ISelectionManager // Allow selection when using a specific modifier key, even when disabled if (!this._enabled) { - const shouldForceSelection = Browser.isMac ? event.altKey : event.shiftKey; - - if (!shouldForceSelection) { + if (!this.shouldForceSelection(event)) { return; } diff --git a/src/Terminal.ts b/src/Terminal.ts index 394fb4de..dd32d266 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -943,7 +943,12 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT ev.preventDefault(); this.focus(); - if (!this.mouseEvents) return; + // Don't send the mouse button to the pty if mouse events are disabled or + // if the selection manager is having selection forced (ie. a modifier is + // held). + if (!this.mouseEvents || this.selectionManager.shouldForceSelection(ev)) { + return; + } // send the button sendButton(ev);