Skip to content

Fix wrap symbol background on homolog pairs in side-by-side#2160

Open
igrmk wants to merge 2 commits into
dandavison:mainfrom
igrmk:fix-wrap-symbol-non-emph-bg
Open

Fix wrap symbol background on homolog pairs in side-by-side#2160
igrmk wants to merge 2 commits into
dandavison:mainfrom
igrmk:fix-wrap-symbol-non-emph-bg

Conversation

@igrmk
Copy link
Copy Markdown

@igrmk igrmk commented May 17, 2026

Wrap symbols in side-by-side in homolog should inherit the line's non-emph background

Symptom

In side-by-side mode only, in a homolog, the wrap continuation symbol is painted as minus-style / plus-style
while the surrounding content is in minus-non-emph-style / plus-non-emph-style.

The bug is only visible when minus-style and minus-non-emph-style (or plus-style and plus-non-emph-style)
are configured with different background colors.
Delta's defaults give each pair the same background — so the bug appears only in custom themes.

Self-contained reproduction against this repo at terminal width 160:

COLUMNS=160 git --no-pager show d2765a48 -- src/cli.rs | head -30 \
  | delta --no-gitconfig --side-by-side --width 160 \
      --minus-style          'white "#785c5a"' \
      --minus-emph-style     'bold white "#785c5a"' \
      --minus-non-emph-style 'white "#454550"' \
      --plus-style           'white "#5b6d5a"' \
      --plus-emph-style      'bold white "#5b6d5a"' \
      --plus-non-emph-style  'white "#454550"'

Before

before

After

after

Root cause

wrap_minusplus_block (src/wrapping.rs) hard-codes fill_style to {minus,plus}_style regardless of whether the pair has a homolog.
That fill_style becomes the background of the wrap continuation symbol and any right-aligned padding spaces.

But when a minus/plus pair has a homolog, the rest of the painted bg is {minus,plus}_non_emph_style
(set by Painter::get_should_right_fill_background_color_and_fill_style in paint.rs via the line_has_homolog == Some(true) branch).
So the wrap symbols and padding pick a bg that doesn't match the line they're embedded in.

Fix

Compute fill_style per alignment pair:

  • (Some, None) or (None, Some) — unpaired line, no homolog: keep {minus,plus}_style.
  • (Some, Some) — paired with homolog: use {minus,plus}_non_emph_style.

igrmk added 2 commits May 17, 2026 00:55
In wrap_minusplus_block the continuation symbol and padding used
minus-style / plus-style even when the rest of the line was painted
with non-emph, leaving a visibly mismatched chip.

Pick fill_style per alignment pair: non-emph for homologs (Some, Some),
minus-style / plus-style for standalone lines.
Companion to the homolog-pair fix. A standalone wrapped line drew its
wrap symbol and padding from minus/plus-style, ignoring a map-styles
repaint of the content, so a remapped moved line kept the old color on
the wrap chrome. Derive the fill from the line's last painted style.
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