From 865f835a5e8a1c7034015bd6b4eee6a8cc7f7763 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Mon, 25 May 2026 17:36:56 -0700 Subject: [PATCH] fix(addon-search): refresh highlights when decoration options change Compare decoration style fields in didOptionsChange so same-term searches with updated colors or rulers trigger highlight recomputation. Co-authored-by: Cursor --- addons/addon-search/src/SearchState.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/addon-search/src/SearchState.ts b/addons/addon-search/src/SearchState.ts index c5e2c8881..e968fccf3 100644 --- a/addons/addon-search/src/SearchState.ts +++ b/addons/addon-search/src/SearchState.ts @@ -3,7 +3,7 @@ * @license MIT */ -import type { ISearchOptions } from '@xterm/addon-search'; +import type { ISearchDecorationOptions, ISearchOptions } from '@xterm/addon-search'; /** * Manages search state including cached search terms, options tracking, and validation. @@ -71,9 +71,27 @@ export class SearchState { if (this._lastSearchOptions.wholeWord !== newOptions.wholeWord) { return true; } + if (this._didDecorationOptionsChange(this._lastSearchOptions.decorations, newOptions.decorations)) { + return true; + } return false; } + private _didDecorationOptionsChange(previous?: ISearchDecorationOptions, current?: ISearchDecorationOptions): boolean { + if (!previous && !current) { + return false; + } + if (!previous || !current) { + return true; + } + return previous.matchBackground !== current.matchBackground || + previous.matchBorder !== current.matchBorder || + previous.matchOverviewRuler !== current.matchOverviewRuler || + previous.activeMatchBackground !== current.activeMatchBackground || + previous.activeMatchBorder !== current.activeMatchBorder || + previous.activeMatchColorOverviewRuler !== current.activeMatchColorOverviewRuler; + } + /** * Determines if a new search should trigger highlighting updates. * @param term The search term.