Skip to content

fix(editor): keep cursor visible on matching brackets - #259

Merged
fcoury-oai merged 1 commit into
mainfrom
codex/bracket-cursor-contrast
Aug 17, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
codex/bracket-cursor-contrast

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

Bracket matching used selection-strength background contrast. The software block cursor then chose its color against that highlight, even though the cursor replaced the highlighted cell. On themes such as Kanagawa, moving onto a bracket could turn the cursor almost the same color as the surrounding line.

What changed

  • Skip bracket decoration beneath the software block cursor so its normal appearance stays stable.
  • Preserve the theme's bracket fill and use an underline to identify the matching bracket without making it look like a second cursor.
  • Keep both bracket decorations in Insert mode and preserve the terminal cursor's contrast against the visible cell.
  • Add regression coverage for dark and light themes, full and incremental redraws, Visual modes, and subtle or border-only theme styles.

How to Test

  1. Run cargo test -p red --lib bracket -- --test-threads=1. The bracket-matching and cursor-contrast regressions should pass.
  2. Run cargo run -p red --bin red -- src/editor.rs. In Normal mode, press Space t, choose Kanagawa, and move onto and off a matched parenthesis or brace. The block cursor should retain its normal color; the partner should have a subtler fill and underline. Repeat with a light theme such as Latte.
  3. Enter Insert mode next to a bracket pair, then move away from it. Both brackets should be decorated while matched, the terminal cursor should remain visible, and the decorations should clear when the pair is no longer active. Also check that entering Visual mode does not change the cursor color merely because it is on a bracket.

Validation

The full Red test suite passed locally: 2,692 passed, 1 ignored. Strict Clippy (cargo clippy --all-targets --all-features -- -D warnings), formatting, diff checks, and the Red binary build also passed.

@fcoury-oai
fcoury-oai merged commit d80caf9 into main Aug 17, 2026
18 of 20 checks passed
@fcoury-oai
fcoury-oai deleted the codex/bracket-cursor-contrast branch August 17, 2026 17:48
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.

1 participant