Skip to content

Fix cursor visibility on matching backgrounds - #220

Open
NLipatov wants to merge 6 commits into
unstablebuild:mainfrom
NLipatov:fix/cursor-background-visibility
Open

NLipatov wants to merge 6 commits into
unstablebuild:mainfrom
NLipatov:fix/cursor-background-visibility

Conversation

@NLipatov

@NLipatov NLipatov commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Pike uses the same color for the cursor and error highlights, so the cursor disappears
over diagnostics such as an invalid import. Swap the cursor's foreground and background
when its fill matches the visible cell background, keeping block cursor text readable
and respecting reverse video. Compare RGB before applying window opacity so transparent
backgrounds are handled too, and keep the swapped cursor fill opaque.


Validation

  • The full test suite with the race detector, GUI tests, and GUI lint passed.
  • The regression test uses the renderer constructor and covers opacity 1, 0.9, and 0,
    including default colors, reverse video, and an opaque cursor fill after swapping.
  • The original fix was manually verified by the contributor in Pike and other themes.
    The opacity adjustment has automated coverage; manual verification was not repeated.
  • Full lint reported three errcheck errors in unchanged files:
    internal/ide/ideacp/manager.go:367, internal/llm/llamaserver/service.go:522, and
    internal/text/exoeditor/handler.go:583.
  • Generation previously failed because mockgen and protoc were not installed.
    Generation and the e2e suite were not run for the opacity adjustment.

Authorship

Using AI is completely fine and encouraged, especially for reviewing your changes. We ask
so we can route the review: agent-authored code gets an agent review first, while
hand-written code deserves the respect of a human reviewer. Either way, a human who
understands the change must be able to answer questions about it.

  • Written by hand. I would like a human review.
  • Mostly or partially generated by an AI agent, which I reviewed and understand.

Pike's cursor shares its color with error highlights, so it disappears over
diagnostics. Swap the cursor colors on a matching cell background to keep
the cursor and its block glyph visible, including with reverse video.

Signed-off-by: Nikita Lipatov <6stringsohei@gmail.com>
@codecov-commenter

codecov-commenter commented Nov 10, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/term/gui/renderer.go 87.50% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread internal/term/gui/renderer.go Outdated
if cell.Attrs&term.AttrReverse != 0 {
cellBG = tcellToColor(cell.Fg, r.fgColor, r.fgOpacity)
}
if bg != cellBG {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This never matches when guiopacity < 1. Cell colors go through applyOpacity, which premultiplies RGB and lowers alpha, but cursorBackground is always opaque. At opacity 0.9 a red cell resolves to {229 0 0 229} while the cursor is {255 0 0 255}, so nothing swaps.

Compare the colors before opacity is applied. For example, keep the cursor's term.Color on the renderer and compare its TrueColor() with the cell's (falling back to the default fg/bg when the cell color is ColorDefault). Please also add an opacity < 1 case to the table test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

The cursor was compared with premultiplied cell colors, so matching
backgrounds were missed whenever opacity was below one. Compare RGB
before opacity and retain the theme defaults for default-colored cells.

Keep the swapped fill opaque so transparent cursor text cannot hide it.

Signed-off-by: Nikita Lipatov <6stringsohei@gmail.com>
@NLipatov
NLipatov requested a review from ernestrc November 12, 2026 15:07
@ernestrc
ernestrc enabled auto-merge (squash) November 17, 2026 00:04
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