Conversation
There was a problem hiding this comment.
Pull request overview
Implements viewport-wide rainbow bracket pair colorization using theme-provided editor.bracket_rainbow_* and editor.bracket_match_fg colors, and adds an end-to-end test to prevent “no color” regressions (fixes #1051).
Changes:
- Add bracket match + rainbow color fields to theme types and expose them via theme loading/lookup.
- Render rainbow bracket colorization for all brackets in the viewport (in addition to cursor-based bracket matching).
- Add e2e tests asserting bracket colorization uses theme colors.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/fresh-editor/themes/solarized-dark.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/nostalgia.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/nord.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/light.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/high-contrast.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/dracula.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/themes/dark.json | Adds bracket match + rainbow colors to theme definition. |
| crates/fresh-editor/tests/e2e/theme.rs | Adds e2e assertions for bracket highlight/colorization theme colors. |
| crates/fresh-editor/src/view/ui/split_rendering.rs | Threads theme + viewport range into bracket overlay update. |
| crates/fresh-editor/src/view/theme/types.rs | Adds bracket color fields + defaults to theme structs and conversions. |
| crates/fresh-editor/src/view/bracket_highlight_overlay.rs | Implements viewport rainbow overlays + theme-driven colors for bracket overlays. |
Comments suppressed due to low confidence (2)
crates/fresh-editor/src/view/bracket_highlight_overlay.rs:344
- Rainbow colorization depth can be incorrect at the top of the viewport because
scan_startonly looks back by one viewport. If a bracket opens beforescan_startand remains unclosed, the stack atviewport_startwill be missing that context, shifting all colors in the viewport. To make colorization correct, compute the initial stack/depth from the start of the document (or maintain cached depth checkpoints / incremental state) rather than relying on a fixed lookback window.
let viewport_size = viewport_end.saturating_sub(viewport_start);
let scan_start = viewport_start.saturating_sub(viewport_size);
let scan_end = viewport_end.min(buffer.len());
crates/fresh-editor/src/view/bracket_highlight_overlay.rs:395
update_colorizationreplaces overlays over0..buffer.len()on every render, which deletes and recreates all markers in the namespace each time (marker churn) and defeats the intent ofreplace_range_in_namespaceto avoid flicker/churn during viewport-only updates. Consider replacing only in a bounded range (e.g., current viewport or union of previous+current viewport ranges tracked in the overlay struct) so unchanged overlays/markers can be preserved.
overlays.replace_range_in_namespace(&ns, &(0..buffer.len()), new_overlays, marker_list);
true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| while pos < position { | ||
| let bytes = buffer.slice_bytes(pos..pos + 1); | ||
| if !bytes.is_empty() { | ||
| let c = bytes[0] as char; | ||
| if c == opening { | ||
| depth += 1; | ||
| } else if c == closing { | ||
| depth = depth.saturating_sub(1); | ||
| if let Some(&byte) = bytes.first() { | ||
| let c = byte as char; | ||
| if is_opening_bracket(c) { |
There was a problem hiding this comment.
calculate_nesting_depth calls buffer.slice_bytes(pos..pos + 1) for every byte before position. slice_bytes allocates a new Vec<u8> each time, so this becomes extremely expensive (O(n) allocations) when the cursor is far into the file. Consider slicing once (e.g., buffer.slice_bytes(0..position)) and iterating that byte slice, or otherwise iterating without per-byte allocations.
added full rainbow bracket colorization (all brackets in the viewport, not just when the cursor is on one) and a new e2e test to catch “no color” regressions. It uses the theme’s editor.bracket_rainbow_* and editor.bracket_match_fg colors.
a06449b to
c5e8e05
Compare
added full rainbow bracket colorization (all brackets in the viewport, not just when the cursor is on one) and a new e2e test to catch “no color” regressions. It uses the theme’s editor.bracket_rainbow_* and editor.bracket_match_fg colors.
fix #1051