Skip to content

fix(highlight): blend_alpha controls line bg and prefix matches gutter#178

Merged
barrettruth merged 3 commits intomainfrom
fix/hari
Mar 8, 2026
Merged

fix(highlight): blend_alpha controls line bg and prefix matches gutter#178
barrettruth merged 3 commits intomainfrom
fix/hari

Conversation

@barrettruth
Copy link
Owner

Problem

blend_alpha was a no-op for line backgrounds — the transparent path used raw
add_bg and the non-transparent path hardcoded 0.4. DiffsClear.bg was nil on
transparent themes, letting native TS backgrounds bleed through. The +/-
prefix char used native TS colors which didn't match DiffsAddNr in the gutter.

Solution

Collapse transparent/non-transparent branches into a single blend_color call
using blend_alpha for line bg and alpha + 0.3 for intra-line. Use raw
add_fg/del_fg for gutter Nr fg. Set DiffsClear.bg to the resolved bg
fallback. Apply DiffsAddNr/DiffsDeleteNr at p199 on col 0..1 for pw=1 diffs
so the prefix +/- matches the gutter.

Problem: `blend_alpha` was ignored for line backgrounds — transparent
path used raw `add_bg`, non-transparent hardcoded 0.4. `DiffsClear.bg`
was nil on transparent themes, letting native TS bg bleed through.
Gutter Nr fg was blended instead of raw.

Solution: collapse transparent/non-transparent into a single blend path
using `blend_alpha` for line bg and `alpha + 0.3` for intra-line. Use
raw `add_fg`/`del_fg` for gutter Nr fg. Set `DiffsClear.bg` to the
resolved bg fallback. Apply same pattern to conflict regions.
Problem: for regular unified diffs, the `+`/`-` prefix char at col 0
had no diffs.nvim extmark. Native TS `@diff.plus` colored it differently
from `DiffsAddNr` in the gutter.

Solution: add `DiffsAddNr`/`DiffsDeleteNr` at p199 on col 0..1 when
`pw == 1` and `background` is enabled. Suppresses native TS at p100.
@barrettruth barrettruth merged commit 883b142 into main Mar 8, 2026
7 checks passed
@barrettruth barrettruth deleted the fix/hari branch March 8, 2026 18:35
barrettruth added a commit that referenced this pull request Mar 8, 2026
Problem: #178 set `DiffsClear.bg` to a dark fallback (`#1a1a1a`) on
transparent themes, painting a visible solid rectangle where the
terminal background should show through.

Solution: only set `DiffsClear.bg` when `Normal.bg` is defined.
Body lines are already protected by `line_hl_group` (`DiffsAdd`/
`DiffsDelete`), which stacks above `hl_group` bg regardless of
priority.
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