fix(highlight): revert line backgrounds to hl_group+hl_eol (#124)

## Problem

The neogit commit (3d640c2) switched line background extmarks from
`hl_group`+`hl_eol` to `line_hl_group`. Due to [neovim#31151][1],
`line_hl_group` bg overrides `hl_group` bg regardless of extmark
priority. This made `DiffsAddText`/`DiffsDeleteText` intra-line
highlights invisible beneath line backgrounds — the extmarks were
placed correctly but Neovim rendered the line bg on top.

[1]: https://github.com/neovim/neovim/issues/31151

## Solution

Revert line backgrounds to `hl_group`+`hl_eol` where priority stacking
works correctly. Keep `number_hl_group` in a separate point extmark to
prevent gutter color bleeding to adjacent lines. The Neogit highlight
override (clearing their groups to `{}`) is independent and unaffected.
This commit is contained in:
Barrett Ruth 2026-02-15 18:27:39 -05:00 committed by GitHub
parent cb38865b96
commit 028ba5314e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 46 deletions

View file

@ -443,11 +443,18 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
end
if opts.highlights.background and is_diff_line then
local ext = { line_hl_group = line_hl, priority = p.line_bg }
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
end_row = buf_line + 1,
hl_group = line_hl,
hl_eol = true,
priority = p.line_bg,
})
if opts.highlights.gutter then
ext.number_hl_group = number_hl
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
number_hl_group = number_hl,
priority = p.line_bg,
})
end
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, ext)
end
if is_marker and line_len > pw then