Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send mouse events when selection is forced #1091

Merged
merged 1 commit into from
Nov 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion src/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down