From 9309ccc480edfb6d14757069fe604f45d19d9a78 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 25 May 2026 22:33:00 -0700 Subject: [PATCH] Prevent SearchAddon decorations from obscuring canvas text. Remove inline decoration background styling and dispose inactive cached decoration sets so stale overlays do not render over glyphs. Co-authored-by: Cursor --- addons/addon-search/src/SearchAddon.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/addons/addon-search/src/SearchAddon.ts b/addons/addon-search/src/SearchAddon.ts index 6235bd2c1..4bfd6d325 100644 --- a/addons/addon-search/src/SearchAddon.ts +++ b/addons/addon-search/src/SearchAddon.ts @@ -619,7 +619,7 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp } set.decorations.push(decoration); set.disposables.push(decoration); - set.disposables.push(this._registerMatchDecorationRender(decoration, set, decorationOptions.matchBackground, matchBorder)); + set.disposables.push(this._registerMatchDecorationRender(decoration, set, matchBorder)); } return set; } @@ -628,22 +628,24 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp if (!set || set.isActive === isActive) { return; } + if (!isActive) { + this._disposeMatchDecorationSet(set); + return; + } set.isActive = isActive; const overviewRulerOptions = isActive && set.options.matchOverviewRuler ? { color: set.options.matchOverviewRuler } : undefined; for (const decoration of set.decorations) { decoration.options.overviewRulerOptions = overviewRulerOptions; if (decoration.element) { - this._applyMatchDecorationStyle(decoration.element, isActive, set.options.matchBackground, set.options.matchBorder); + this._applyMatchDecorationStyle(decoration.element, isActive, set.options.matchBorder); } } } - private _applyMatchDecorationStyle(element: HTMLElement, isActive: boolean, background: string | undefined, border: string | undefined): void { + private _applyMatchDecorationStyle(element: HTMLElement, isActive: boolean, border: string | undefined): void { if (isActive) { - element.style.backgroundColor = background || ''; element.style.outline = border ? `1px solid ${border}` : ''; } else { - element.style.backgroundColor = ''; element.style.outline = ''; } } @@ -655,11 +657,10 @@ export class SearchAddon extends Disposable implements ITerminalAddon, ISearchAp private _registerMatchDecorationRender( decoration: IDecoration, set: IMatchDecorationSet, - background: string | undefined, border: string | undefined ): IDisposable { return decoration.onRender(element => { - this._applyMatchDecorationStyle(element, set.isActive, background, border); + this._applyMatchDecorationStyle(element, set.isActive, border); }); }