From 63fd3be67acc74048a29369c770cda867ceefa01 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Mon, 12 Aug 2019 17:56:26 -0700 Subject: [PATCH 1/3] Ensure selection service mousedown happens after mouse zone manager Fixes #2380 --- src/Terminal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Terminal.ts b/src/Terminal.ts index ef05c664..07150aad 100644 --- a/src/Terminal.ts +++ b/src/Terminal.ts @@ -643,7 +643,6 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp this.screenElement); this._instantiationService.setService(ISelectionService, this._selectionService); this.register(this._selectionService.onSelectionChange(() => this._onSelectionChange.fire())); - this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService.onMouseDown(e))); this.register(this._selectionService.onRedrawRequest(e => this._renderService.onSelectionChanged(e.start, e.end, e.columnSelectMode))); this.register(this._selectionService.onLinuxMouseSelection(text => { // If there's a new selection, put it into the textarea, focus and select it @@ -664,6 +663,9 @@ export class Terminal extends Disposable implements ITerminal, IDisposable, IInp this.register(this.onScroll(() => this._mouseZoneManager.clearAll())); this.linkifier.attachToDom(this.element, this._mouseZoneManager); + // This event listener must be registered aftre MouseZoneManager is created + this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService.onMouseDown(e))); + // apply mouse event classes set by escape codes before terminal was attached if (this.mouseEvents) { this._selectionService.disable(); From 85444def9f10da776916a35c52b5f995d74ca253 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Fri, 16 Aug 2019 10:50:44 -0400 Subject: [PATCH 2/3] Don't scroll terminal search result if within viewport --- addons/xterm-addon-search/src/SearchAddon.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index e9f8a9b4..caf2915e 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -343,9 +343,13 @@ export class SearchAddon implements ITerminalAddon { return false; } terminal.select(result.col, result.row, result.term.length); - let scroll = result.row - terminal.buffer.viewportY; - scroll = scroll - Math.floor(terminal.rows / 2); - terminal.scrollLines(scroll); + // If it is not in the viewport then we scroll else it just gets selected + if (result.row > (terminal.buffer.viewportY + terminal.rows) || result.row < terminal.buffer.viewportY) { + let scroll = result.row - terminal.buffer.viewportY; + scroll = scroll - Math.floor(terminal.rows / 2); + terminal.scrollLines(scroll); + console.log('scrolling'); + } return true; } } From f3d8e74d6f4f0b11df4d93a1a019bf0de476398b Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Fri, 16 Aug 2019 10:55:16 -0400 Subject: [PATCH 3/3] Remove forgotten console .log --- addons/xterm-addon-search/src/SearchAddon.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index caf2915e..4d3e8841 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -348,7 +348,6 @@ export class SearchAddon implements ITerminalAddon { let scroll = result.row - terminal.buffer.viewportY; scroll = scroll - Math.floor(terminal.rows / 2); terminal.scrollLines(scroll); - console.log('scrolling'); } return true; }