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 <cursoragent@cursor.com>
This commit is contained in:
Daniel Imms
2026-05-25 22:00:36 -07:00
co-authored by Cursor
parent 2da6c9b9b7
commit ef84237ef3
+9 -1
View File
@@ -40,6 +40,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
private _lastSearchKey: string | undefined; private _lastSearchKey: string | undefined;
private _resultCount = 0; private _resultCount = 0;
private _resultIndex = -1; private _resultIndex = -1;
private _pendingResultRefresh = false;
private readonly _matchCache = new Map<number, Map<number, Map<string, IMatch[] | undefined>>>(); private readonly _matchCache = new Map<number, Map<number, Map<string, IMatch[] | undefined>>>();
private readonly _matchCacheOrder: IMatchCacheKey[] = []; private readonly _matchCacheOrder: IMatchCacheKey[] = [];
private _logicalLineCache: ILogicalLineCache | undefined; private _logicalLineCache: ILogicalLineCache | undefined;
@@ -181,7 +182,14 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp
return; return;
} }
this._resultsUpdateListener.value = terminal.onWriteParsed(() => { this._resultsUpdateListener.value = terminal.onWriteParsed(() => {
this._refreshResultsAfterBufferChange(); if (this._pendingResultRefresh) {
return;
}
this._pendingResultRefresh = true;
queueMicrotask(() => {
this._pendingResultRefresh = false;
this._refreshResultsAfterBufferChange();
});
}); });
} }