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 <cursoragent@cursor.com>
This commit is contained in:
Daniel Imms
2026-05-25 17:36:56 -07:00
co-authored by Cursor
parent bf055dd5fc
commit 865f835a5e
+19 -1
View File
@@ -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.