Skip to content

fix: glyph under the block cursor invisible on INVERSE/selected cells#86

Merged
Harzu merged 1 commit into
Harzu:masterfrom
Patrick-Kappen:fix/cursor-glyph-inverse
Jul 18, 2026
Merged

fix: glyph under the block cursor invisible on INVERSE/selected cells#86
Harzu merged 1 commit into
Harzu:masterfrom
Patrick-Kappen:fix/cursor-glyph-inverse

Conversation

@Patrick-Kappen

Copy link
Copy Markdown
Contributor

Problem

The block cursor rect is painted in the cell's pre-swap fg color, but the glyph on top of it is recolored to the post-swap bg — and only when APP_CURSOR is set, a keypad/cursor-keys mode that has nothing to do with rendering.

On a cell with the INVERSE flag or inside a selection, the fg/bg swap has already happened by then, so glyph and cursor rect end up the same color: the character under the cursor disappears. Easy to hit in practice:

  • nvim: the character under the cursor vanishes (nvim renders its cursor cell inverse)
  • selecting across the shell prompt: the letter under the block cursor blinks out

Minimal repro in a plain shell:

printf 'X\e[7mY\e[27mZ\e[2D'; sleep 5   # cursor ends on the inverse Y

Before: X▮Z — the Y is invisible inside the cursor block. After: XYZ with the Y readable inside the block.

Fix

Capture the cell's pre-swap bg and use it for the glyph whenever the cursor is shown on that cell (SHOW_CURSOR), unconditionally — the cursor rect is painted in the pre-swap fg, so the pre-swap bg is the contrasting color regardless of INVERSE/selection. Also drops the unrelated APP_CURSOR gate: without it, the glyph under the cursor was invisible in the (common) non-application-mode case too, whenever cell fg ≈ cursor color.

The cursor rect is painted in the cell's pre-swap fg; the glyph on it
was recolored to the post-swap bg, and only under APP_CURSOR — a
keypad mode unrelated to rendering. On a cell with the INVERSE flag or
inside a selection the fg/bg swap made glyph and rect the same color:
the character under the cursor disappeared (e.g. nvim's cursor cell,
or selecting across the shell prompt). Recolor with the pre-swap cell
bg whenever the cursor is shown (SHOW_CURSOR), unconditionally.
@Harzu
Harzu merged commit 67c00e1 into Harzu:master Jul 18, 2026
24 checks passed
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.

3 participants