Skip to content

impl bracket color #1051#1088

Draft
asukaminato0721 wants to merge 1 commit intosinelaw:masterfrom
asukaminato0721:1051
Draft

impl bracket color #1051#1088
asukaminato0721 wants to merge 1 commit intosinelaw:masterfrom
asukaminato0721:1051

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

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

@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 22, 2026 09:59
Copilot AI review requested due to automatic review settings February 22, 2026 09:59
@asukaminato0721 asukaminato0721 marked this pull request as draft February 22, 2026 09:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_start only looks back by one viewport. If a bracket opens before scan_start and remains unclosed, the stack at viewport_start will 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_colorization replaces overlays over 0..buffer.len() on every render, which deletes and recreates all markers in the namespace each time (marker churn) and defeats the intent of replace_range_in_namespace to 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.

Comment on lines 226 to +230
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) {
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support rainbow bracket

2 participants