From b162582e668398179d440aca8629a0f2b6cbfc6d Mon Sep 17 00:00:00 2001 From: npezza93 Date: Sat, 21 Apr 2018 08:52:12 -0400 Subject: [PATCH 1/2] Handle if getCoords returns null in the AltClickHandler Fixes #1397 --- src/handlers/AltClickHandler.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index 85465272..6b980fe6 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -28,7 +28,7 @@ export class AltClickHandler { this._startCol = this._terminal.buffer.x; this._startRow = this._terminal.buffer.y; - [this._endCol, this._endRow] = this._terminal.mouseHelper.getCoords( + let coordinates = this._terminal.mouseHelper.getCoords( this._mouseEvent, this._terminal.element, this._terminal.charMeasure, @@ -36,7 +36,13 @@ export class AltClickHandler { this._terminal.cols, this._terminal.rows, false - ).map((coordinate: number) => { + ); + + if (!coordinates) { + return null; + } + + [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { return coordinate - 1; }); } From 4edbd507e5717669ebe57c20657053fa9bae06c9 Mon Sep 17 00:00:00 2001 From: npezza93 Date: Wed, 9 May 2018 19:35:02 -0400 Subject: [PATCH 2/2] Check if endCol and endRow are present before handling an alt click --- src/handlers/AltClickHandler.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/handlers/AltClickHandler.ts b/src/handlers/AltClickHandler.ts index 6b980fe6..7f2e4f05 100644 --- a/src/handlers/AltClickHandler.ts +++ b/src/handlers/AltClickHandler.ts @@ -38,20 +38,18 @@ export class AltClickHandler { false ); - if (!coordinates) { - return null; + if (coordinates) { + [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { + return coordinate - 1; + }); } - - [this._endCol, this._endRow] = coordinates.map((coordinate: number) => { - return coordinate - 1; - }); } /** * Writes the escape sequences of arrows to the terminal */ public move(): void { - if (this._mouseEvent.altKey) { + if (this._mouseEvent.altKey && this._endCol !== undefined && this._endRow !== undefined) { this._terminal.send(this._arrowSequences()); } }