From 7fa32af0513cb40c7033b4dcd89e861caecc9b59 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 27 Apr 2022 11:20:00 -0700 Subject: [PATCH] clear `cachedSearchTerm` when decorations are cleared (#3750) --- addons/xterm-addon-search/src/SearchAddon.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index ef3ba2fc..241e5e99 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -102,7 +102,7 @@ export class SearchAddon implements ITerminalAddon { this._onDataDisposable?.dispose(); } - public clearDecorations(): void { + public clearDecorations(internal?: boolean): void { this._selectedDecoration?.dispose(); this._searchResults?.clear(); this._resultDecorations?.forEach(decorations => { @@ -113,6 +113,13 @@ export class SearchAddon implements ITerminalAddon { this._resultDecorations?.clear(); this._searchResults = undefined; this._resultDecorations = undefined; + if (!internal) { + // we want to keep _cachedSearchTerm defined if this is + // an internal call + // so that when the buffer changes, + // we can use that to search for new matches + this._cachedSearchTerm = undefined; + } } /** @@ -146,7 +153,7 @@ export class SearchAddon implements ITerminalAddon { searchOptions = searchOptions || {}; // new search, clear out the old decorations - this.clearDecorations(); + this.clearDecorations(true); this._searchResults = new Map(); this._resultDecorations = new Map(); const resultDecorations = this._resultDecorations;