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:
@@ -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<number, Map<number, Map<string, IMatch[] | undefined>>>();
|
||||
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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user