add disposeDecorations helper

This commit is contained in:
meganrogge
2022-03-21 15:45:45 -04:00
parent fefdd8a4e9
commit 866ee23df9
+7 -4
View File
@@ -90,12 +90,16 @@ export class SearchAddon implements ITerminalAddon {
this._selectedDecoration?.dispose();
this._terminal?.clearSelection();
this._searchResults.clear();
this._resultDecorations.forEach(decorations => decorations.forEach(d=> d.dispose()));
this._resultDecorations.clear();
this._disposeDecorations();
this._cachedSearchTerm = undefined;
this._dataChanged = true;
}
private _disposeDecorations(): void {
this._resultDecorations.forEach(decorations => decorations.forEach(d=> d.dispose()));
this._resultDecorations.clear();
}
/**
* Find the next instance of the term, then scroll to and select it. If it
* doesn't exist, do nothing.
@@ -124,8 +128,7 @@ export class SearchAddon implements ITerminalAddon {
return selectionType === SelectionType.NEXT ? this._findAndSelectNext(term, searchOptions) : this._findAndSelectPrevious(term, searchOptions);
}
// new search, clear out the old decorations
this._resultDecorations.forEach(decorations => decorations.forEach(d=> d.dispose()));
this._resultDecorations.clear();
this._disposeDecorations();
this._searchResults.clear();
if (!this._terminal.options.overviewRulerWidth) {