From 50ba6bfa1b32093241070ec2ce89443226ba6f27 Mon Sep 17 00:00:00 2001 From: rishab Date: Sat, 25 Apr 2020 03:13:19 -0700 Subject: [PATCH 1/3] Wrap search back if there exists a result in search Search must wrap back as it does when there are multiple lines. --- addons/xterm-addon-search/src/SearchAddon.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index ba8dbc0728..fa473a71be 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -110,8 +110,16 @@ export class SearchAddon implements ITerminalAddon { } } - // If there is only one result, return true. if (!result && currentSelection) return true; + // If there is only one result, wrap back and return selection if exists. + if (!result && currentSelection) { + searchPosition.startRow = currentSelection.startRow; + searchPosition.startCol = 0; + result = this._findInLine(term, searchPosition, searchOptions); + if (result) { + return this._selectResult(result); + } + } // Set selection and scroll if a result was found return this._selectResult(result); From 45ff3ee6379c2fb1c775fa953cd12eed77c932b5 Mon Sep 17 00:00:00 2001 From: rishab Date: Sat, 25 Apr 2020 03:13:32 -0700 Subject: [PATCH 2/3] Update SearchAddon.ts --- 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 fa473a71be..e22c8b7c85 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -110,7 +110,6 @@ export class SearchAddon implements ITerminalAddon { } } - if (!result && currentSelection) return true; // If there is only one result, wrap back and return selection if exists. if (!result && currentSelection) { searchPosition.startRow = currentSelection.startRow; From 08f8f51adee6dfbfa19e1e6cbf6a377da456719a Mon Sep 17 00:00:00 2001 From: rishab Date: Sat, 25 Apr 2020 17:33:48 -0700 Subject: [PATCH 3/3] handle wrap back with find previous wrap back search selection to last selected result when we hit top --- addons/xterm-addon-search/src/SearchAddon.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index e22c8b7c85..f5505689f5 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -110,14 +110,11 @@ export class SearchAddon implements ITerminalAddon { } } - // If there is only one result, wrap back and return selection if exists. + // If there is only one result, wrap back and return selection if it exists. if (!result && currentSelection) { searchPosition.startRow = currentSelection.startRow; searchPosition.startCol = 0; result = this._findInLine(term, searchPosition, searchOptions); - if (result) { - return this._selectResult(result); - } } // Set selection and scroll if a result was found @@ -182,7 +179,7 @@ export class SearchAddon implements ITerminalAddon { } // If we hit the top and didn't search from the very bottom wrap back down if (!result && startRow !== (this._terminal.buffer.active.baseY + this._terminal.rows)) { - for (let y = (this._terminal.buffer.active.baseY + this._terminal.rows); y > startRow; y--) { + for (let y = (this._terminal.buffer.active.baseY + this._terminal.rows); y >= startRow; y--) { searchPosition.startRow = y; result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); if (result) {