From 50ba6bfa1b32093241070ec2ce89443226ba6f27 Mon Sep 17 00:00:00 2001 From: rishab Date: Sat, 25 Apr 2020 03:13:19 -0700 Subject: [PATCH] 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 ba8dbc072..fa473a71b 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);