From ef84237ef30e2547a0bdd00c8b5a9fac158aa4de Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 25 May 2026 22:00:36 -0700 Subject: [PATCH] Coalesce write-triggered decoration refreshes within the same tick. This avoids redundant match/decorations recomputation during bursts of parsed writes while preserving the latest refresh result. Co-authored-by: Cursor --- addons/addon-search/src/SearchAddon.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/addon-search/src/SearchAddon.ts b/addons/addon-search/src/SearchAddon.ts index 98a9bf810..e93c422e1 100644 --- a/addons/addon-search/src/SearchAddon.ts +++ b/addons/addon-search/src/SearchAddon.ts @@ -40,6 +40,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp private _lastSearchKey: string | undefined; private _resultCount = 0; private _resultIndex = -1; + private _pendingResultRefresh = false; private readonly _matchCache = new Map>>(); private readonly _matchCacheOrder: IMatchCacheKey[] = []; private _logicalLineCache: ILogicalLineCache | undefined; @@ -181,7 +182,14 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp return; } this._resultsUpdateListener.value = terminal.onWriteParsed(() => { - this._refreshResultsAfterBufferChange(); + if (this._pendingResultRefresh) { + return; + } + this._pendingResultRefresh = true; + queueMicrotask(() => { + this._pendingResultRefresh = false; + this._refreshResultsAfterBufferChange(); + }); }); }