Fix block cursor glyph visibility when colors collide - #2491
Open
sinelaw wants to merge 1 commit into
Open
Conversation
sinelaw
force-pushed
the
claude/wonderful-bell-kbf8lu
branch
from
June 26, 2026 16:19
50701b5 to
2d0fdc4
Compare
A hardware block cursor is drawn by the terminal: it fills the cursor cell's background with the theme cursor color (sent via OSC 12) but leaves the glyph in its own foreground color. The primary cursor cell deliberately skips the software REVERSED modifier (it double-inverts inside multiplexers like tmux/zellij), so a glyph whose foreground is close to — or identical with — the cursor color is hard to read or vanishes entirely (e.g. a syntax.keyword token in Dracula, where the keyword and cursor share a color). Always repaint the block-cursor cell's glyph to a high-contrast color (black or white by the cursor color's luminance), independent of the glyph's own color, so the cursor reads like a normal reverse-video block. The recolor is applied after color conversion so the 256-color contrast pass cannot undo it, and only the single cursor cell is touched. Bar/underline cursors leave the glyph visible and are unaffected; an unresolvable cursor color (no OSC 12) is left to the terminal's own cursor. Two existing rendering tests sampled the exact cell the caret sits on (the first ANSI block; line 1's keyword in the CRLF highlight test); move their caret off the sampled cells so they observe content color rather than the cursor glyph. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ta2tojr71nT75V96rmz9ci
sinelaw
force-pushed
the
claude/wonderful-bell-kbf8lu
branch
from
July 17, 2026 11:55
2d0fdc4 to
f975137
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an issue where glyphs under a block cursor become invisible when their foreground color matches the terminal cursor color (e.g., a keyword token in Dracula theme where both share the same magenta color).
Changes
Glyph collision detection and fix: Added
fix_block_cursor_glyph_collision()method that detects when a glyph's foreground exactly matches the cursor color and recolors it to maintain visibilityCursor style classification: Added
is_block()method toCursorStyleto identify which cursor styles fully cover the glyph cell (block cursors) versus those that leave it visible (bar/underline)Theme color override utility: Added
override_theme_colors()method to Editor for test support, allowing runtime color manipulation to reproduce specific collision scenariosComprehensive test coverage:
Implementation Details
The fix avoids using the software
REVERSEDmodifier (which would double-invert in multiplexers like tmux/zellij) and instead performs a targeted foreground inversion only on the colliding glyph. The replacement color selection prioritizes the cell's own background, then falls back to editor background and foreground to ensure the result never collides with the cursor color itself.https://claude.ai/code/session_01Ta2tojr71nT75V96rmz9ci