From 2275601bf7ce70ba2c10a2103d1439d0060c1879 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 14:22:30 +0200 Subject: [PATCH 1/5] Removed unused constants from the selection manager --- src/SelectionManager.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/SelectionManager.ts b/src/SelectionManager.ts index ac7fd01778..31ee8c2c8f 100644 --- a/src/SelectionManager.ts +++ b/src/SelectionManager.ts @@ -27,18 +27,6 @@ const DRAG_SCROLL_MAX_SPEED = 15; */ const DRAG_SCROLL_INTERVAL = 50; -/** - * The amount of time before mousedown events are no longer stacked to create - * double/triple click events. - */ -const CLEAR_MOUSE_DOWN_TIME = 400; - -/** - * The number of pixels in each direction that the mouse must move before - * mousedown events are no longer stacked to create double/triple click events. - */ -const CLEAR_MOUSE_DISTANCE = 10; - /** * A string containing all characters that are considered word separated by the * double click to select work logic. From 0af4b17c20c384c3985e78d949c08006b88977d4 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 15:56:14 +0200 Subject: [PATCH 2/5] Guard public selection api --- src/xterm.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index d625a3cfc2..6be1367598 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1437,7 +1437,7 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) { * Gets whether the terminal has an active selection. */ Terminal.prototype.hasSelection = function() { - return this.selectionManager.hasSelection; + return !!(this.selectionManager && this.selectionManager.hasSelection); }; /** @@ -1445,21 +1445,25 @@ Terminal.prototype.hasSelection = function() { * behavior outside of xterm.js. */ Terminal.prototype.getSelection = function() { - return this.selectionManager.selectionText; + return this.selectionManager ? this.selectionManager.selectionText : ''; }; /** * Clears the current terminal selection. */ Terminal.prototype.clearSelection = function() { - this.selectionManager.clearSelection(); + if (this.selectionManager) { + this.selectionManager.clearSelection(); + } }; /** * Selects all text within the terminal. */ Terminal.prototype.selectAll = function() { - this.selectionManager.selectAll(); + if (this.selectionManager) { + this.selectionManager.selectAll(); + } }; /** From 1cc0d43aa41025bf2f1b46eedad58034a40da004 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 14:00:55 +0200 Subject: [PATCH 3/5] Clear selection on input --- src/xterm.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/xterm.js b/src/xterm.js index d625a3cfc2..16c88a914c 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -2234,6 +2234,11 @@ Terminal.prototype.handler = function(data) { return; } + // Clear the selection + if (this.hasSelection()) { + this.clearSelection(); + } + // Input is being sent to the terminal, the terminal should focus the prompt. if (this.ybase !== this.ydisp) { this.scrollToBottom(); From 1b6ce6dab640bd8ecefff9a5fbafd7fa79d9ac57 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 15:18:12 +0200 Subject: [PATCH 4/5] Make sure selection manager is available (only after open() was called) --- src/xterm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index 16c88a914c..c18277e7ea 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -2234,9 +2234,9 @@ Terminal.prototype.handler = function(data) { return; } - // Clear the selection - if (this.hasSelection()) { - this.clearSelection(); + // Clear the selection if the selection manager is available and has an active selection + if (this.selectionManager && this.selectionManager.hasSelection) { + this.selectionManager.clearSelection(); } // Input is being sent to the terminal, the terminal should focus the prompt. From 6df6aad3038b6c56b21c0e4f42151eedb5406243 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 18:41:55 +0200 Subject: [PATCH 5/5] Improve guard expression for hasSelection --- src/xterm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xterm.js b/src/xterm.js index 6be1367598..f82d46b5ed 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1437,7 +1437,7 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) { * Gets whether the terminal has an active selection. */ Terminal.prototype.hasSelection = function() { - return !!(this.selectionManager && this.selectionManager.hasSelection); + return this.selectionManager ? this.selectionManager.hasSelection : false; }; /**