Skip to content

Honour View.SelFgColor for the highlighted line in setCharacter - #107

Open
0x3654 wants to merge 1 commit into
jesseduffield:masterfrom
0x3654:honour-selfgcolor-in-setcharacter
Open

0x3654 wants to merge 1 commit into
jesseduffield:masterfrom
0x3654:honour-selfgcolor-in-setcharacter

Conversation

@0x3654

@0x3654 0x3654 commented Sep 6, 2026 •

Copy link
Copy Markdown

Honour View.SelFgColor for the highlighted line in setRune

View exposes both SelBgColor and SelFgColor, but the per-rune draw path
(setRune) only ever applies SelBgColor: the foreground is force-brightened
(the +8 variant of the cell's colour) and emboldened, and SelFgColor is
silently ignored (SelFgColor is currently only honoured by SetHighlight,
which list-style consumers don't use). Consumers therefore can't offer a
readable "dark text on a bright selection background" style: the brightening
fights it.

This makes setRune apply SelFgColor when it is set:

  • every cell of the selected line takes the selected foreground, discarding
    its own colour — the line renders as a uniform plate;
  • plain-text cells (no colour of their own) keep the classic bold emphasis,
    coloured cells render regular weight;
  • if either selection attribute carries reverse, the legacy behaviour is
    kept: reverse swaps fg/bg at the terminal, so an explicit foreground would
    land on a terminal-theme-dependent colour after the swap;
  • when SelFgColor is unset (the default), rendering is unchanged.

Covered by TestSetCharacterSelection, which drives setCharacter
through a headless (simulation-screen) Gui and asserts the final tcell
style of the selected cell; it fails on master.

Companion consumer PR: jesseduffield/lazydocker #839 adds an opt-in
selectedLineFgColor theme key on top of this.

View exposes both SelBgColor and SelFgColor, but the per-rune draw path
only ever applies SelBgColor: the foreground is force-brightened (the +8
variant of the cell's own colour) and emboldened, and SelFgColor is
silently ignored (it is currently only honoured by SetHighlight, which
list-style consumers don't use). Consumers therefore can't offer a
readable "dark text on a bright selection background" style: the
brightening fights it.

Apply SelFgColor in setCharacter when it is set: every cell of the
selected line takes the selected foreground, plain cells (no colour of
their own) keep the classic bold emphasis, coloured cells render regular
weight. If either selection attribute carries reverse, keep the legacy
behaviour: reverse swaps fg/bg at the terminal, so an explicit foreground
would land on a terminal-theme-dependent colour after the swap. With
SelFgColor unset (the default), rendering is unchanged.

Co-Authored-By: Claude Code <noreply@anthropic.com>
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