From b6074df4bf76e996fea449dc718a2122ceeab30a Mon Sep 17 00:00:00 2001 From: Ken Aoki Date: Tue, 13 Oct 2020 06:44:01 +0000 Subject: [PATCH] Revert "Fix search not expanding selection to left when appropriate" This reverts commit a9d2b8a55c40b4d0b477edba5ef3c7d2f1d9fd4e. --- addons/xterm-addon-search/src/SearchAddon.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 561794e1..f5505689 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -141,14 +141,14 @@ export class SearchAddon implements ITerminalAddon { const isReverseSearch = true; let startRow = this._terminal.buffer.active.baseY + this._terminal.rows; let startCol = this._terminal.cols; + let result: ISearchResult | undefined; + const incremental = searchOptions ? searchOptions.incremental : false; let currentSelection: ISelectionPosition | undefined; if (this._terminal.hasSelection()) { - const incremental = searchOptions ? searchOptions.incremental : false; - // Start from selection start if there is a selection - // For incremental search, use selection end currentSelection = this._terminal.getSelectionPosition()!; - startRow = incremental ? currentSelection.endRow : currentSelection.startRow; - startCol = incremental ? currentSelection.endColumn : currentSelection.startColumn; + // Start from selection start if there is a selection + startRow = currentSelection.startRow; + startCol = currentSelection.startColumn; } this._initLinesCache(); @@ -157,8 +157,14 @@ export class SearchAddon implements ITerminalAddon { startCol }; - // Search startRow - let result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); + if (incremental) { + result = this._findInLine(term, searchPosition, searchOptions, false); + if (!(result && result.row === startRow && result.col === startCol)) { + result = this._findInLine(term, searchPosition, searchOptions, true); + } + } else { + result = this._findInLine(term, searchPosition, searchOptions, isReverseSearch); + } // Search from startRow - 1 to top if (!result) {