Repository navigation
editorFind: fix swapped findMatch foreground colors (#228782) - #270395
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the editor.findMatchForeground and editor.findMatchHighlightForeground color settings were incorrectly swapped in the find widget implementation. The fix ensures that the documented color semantics are properly applied to their intended elements.
- Corrected assignment of
editor.findMatchForegroundto target the current search match - Corrected assignment of
editor.findMatchHighlightForegroundto target other search matches
|
The corrected token mapping looks right, but could we also preserve current-match precedence when changing these rules? Both selectors have equal specificity. With this patch, Notebook repro to verify with this PR applied
Expected: the current match has black text; the other match has red text. With the PR's rule order: the current match also resolves to red, so the foreground distinction between current and other matches is lost. The notebook path makes the overlap concrete: Suggested fixKeep the corrected mapping, but emit the ordinary-match rule first and the current-match rule last: const findMatchHighlightForeground = theme.getColor(editorFindMatchHighlightForeground);
if (findMatchHighlightForeground) {
collector.addRule(`.monaco-editor .findMatchInline { color: ${findMatchHighlightForeground}; }`);
}
const findMatchForeground = theme.getColor(editorFindMatchForeground);
if (findMatchForeground) {
collector.addRule(`.monaco-editor .currentFindMatchInline { color: ${findMatchForeground}; }`);
}This fixes the swapped mapping while retaining the original current-class priority. Please also cover a span with both classes and distinct foreground colors in regression testing; testing the selectors separately misses this case. Validation: I traced the decoration producers and verified the CSS cascade in Chromium: with the PR's rules, current-only is black, other-only is red, and overlapping is red; emitting the current rule last makes overlapping black. I have not run the notebook scenario end to end. |
Dmitriy Vasyura (dmitrivMS)
left a comment
There was a problem hiding this comment.
Please consider feedback in the comment
|
Good catch, fixed in 9344871. Verified with the notebook repro that a span with both classes now resolves to findMatchForeground. |
|
hirose (@hirossan4049) Thank you! |
Summary
Fixes #228782
Fixes an issue where the
editor.findMatchForegroundandeditor.findMatchHighlightForegroundcolor settings were swapped.Problem
The find match foreground colors were incorrectly assigned:
editor.findMatchForeground(documented as “current search match”) was applied to other matches.editor.findMatchHighlightForeground(documented as “other search matches”) was applied to the current match.Solution
Swapped the CSS class selectors in
findWidget.ts:editor.findMatchForegroundnow correctly targets.currentFindMatchInline(current match)editor.findMatchHighlightForegroundnow correctly targets.findMatchInline(other matches)Before
After
Test Plan
editor.findMatchForegroundto a distinct color and verify it colors the current match.editor.findMatchHighlightForegroundto a distinct color and verify it colors other matches.