From 866ee23df9ab7dd0bd3185255307e6cbba15eb14 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 21 Mar 2022 15:45:45 -0400 Subject: [PATCH] add disposeDecorations helper --- addons/xterm-addon-search/src/SearchAddon.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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) {