diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index bc27e4e4..5451b832 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -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) {