clear cachedSearchTerm when decorations are cleared (#3750)

This commit is contained in:
Megan Rogge
2022-04-27 18:20:00 +00:00
committed by GitHub
parent fa92e6074d
commit 7fa32af051
+9 -2
View File
@@ -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<string, ISearchResult>();
this._resultDecorations = new Map<number, IDecoration[]>();
const resultDecorations = this._resultDecorations;