From 85444def9f10da776916a35c52b5f995d74ca253 Mon Sep 17 00:00:00 2001 From: Logan Ramos Date: Fri, 16 Aug 2019 10:50:44 -0400 Subject: [PATCH] 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; } }