bug: header line backgrounds don't cover quote prefix on email-quoted diffs #142
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
barrettruth/diffs.nvim#142
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When parsing email-quoted diffs (
> diff --git ...), the diff treesitter grammar applies@diff.plus.diffand@diff.minus.diffcaptures to+++/---header lines. These captures start atcol = quote_width(e.g. col 2 for>prefix), leaving the quote prefix area (col 0–1) with no background highlight.The non-quoted version covers the full line (col 0 to EOL), so the visual difference is jarring — the quoted header lines have a colored background on only part of the line.
Affected lines:
> --- a/...,> +++ b/....Proposed fix
When
quote_width > 0, detect---/+++header lines and add a full-line background extmark (hl_eol = true, col 0) matching the@diff.plus/@diff.minushighlight, just like hunk body lines already getDiffsAdd/DiffsDeleteline backgrounds. The>prefix stays visible in the buffer — buffers should show their actual content — but the background covers the full line.Conceal is the wrong approach. Hiding the quote prefix, if desired, should be opt-in via
hide_prefix, not forced.Context
Introduced by the email-quoted diff parsing feature (#141). The core parsing and highlight offset logic works correctly — this is a visual polish issue specific to header lines.
Progress
Investigated and partially fixed. The issue was deeper than just header line backgrounds.
Root cause
DiffsClearonly definedfg(Normal foreground). In Neovim's extmark priority model, each highlight attribute (fg, bg, bold, etc.) is resolved independently across the priority stack. A higher-priority extmark that only definesfgdoes not suppress a lower-priority extmark'sbg. This meant native treesitter's wrong backgrounds (from misinterpreting>-prefixed lines) bled through everywhereDiffsClearwas applied.Fixes applied
DiffsClearnow defines bothfgandbg(init.lua) — suppresses native treesitter backgroundsDiffsClearat col 0 whenqw > 0— clears native TS before re-applying diff grammar treesitter at elevated priority (199 vs default 100)@@line gets explicit highlighting whenqw > 0— was previously unhandled (not inheader_lines, not a body line), now getsDiffsClear+ diff grammar treesitter>prefix getsDiffsClear(col 0→qw) — suppresses native TS on the quote prefixRemaining issues
qwon context lines: Between prefix DiffsClear (0→qw) and content DiffsClear (pw+qw→EOL), context body lines have a 1-column gap where native TS bg can bleed through. Masked on +/- lines by DiffsAdd/DiffsDelete at p200.>context lines: May not get full DiffsClear coverage (line_len ≤ pw so content DiffsClear never fires).+/-at colqwlacks diff-grammar fg in quoted mode (native TS can't parse> +...).Config option idea
Should there be a config option to hide the
>quote prefix (viahide_prefixor a newhide_quote_prefix)? The buffer content stays unchanged, but the prefix would be visually concealed. This is separate from the background fix.NOTE: we see a green bg flash on the second code portion of
in the current impl, indicating inconsistent hl (this not seen in section 1) and possibly related to #143
closed in #149