fix(highlight): make intra-line bg visible under line backgrounds
Problem: `line_hl_group` bg unconditionally overrides `hl_group` bg regardless of priority (neovim/neovim#31151). `DiffsAddText`/ `DiffsDeleteText` at p201 were invisible under `DiffsAdd`/`DiffsDelete` `line_hl_group` at p200 because they operate on separate stacking layers. Solution: replace `line_hl_group` with `hl_group` + `hl_eol` + `end_col` for line backgrounds, putting them on the same layer as intra-line highlights so priority governs stacking. Use single-row extmarks (`end_row = buf_line`) to avoid the adjacent-hunk clearing bug. Split `number_hl_group` into a separate extmark. Use raw `DiffAdd.bg`/`DiffDelete.bg` for `DiffsAddText`/`DiffsDeleteText` instead of alpha-blending toward Normal.bg, which produced indistinguishable colors on dark themes.
This commit is contained in:
parent
a1af48833b
commit
8c41c7007c
5 changed files with 47 additions and 34 deletions
|
|
@ -636,11 +636,20 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
end
|
||||
|
||||
if opts.highlights.background and is_diff_line then
|
||||
local bg_end_col = raw_len or (line_len + qw)
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
|
||||
line_hl_group = line_hl,
|
||||
number_hl_group = opts.highlights.gutter and number_hl or nil,
|
||||
end_row = buf_line,
|
||||
end_col = bg_end_col,
|
||||
hl_group = line_hl,
|
||||
hl_eol = true,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
if opts.highlights.gutter then
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
|
||||
number_hl_group = number_hl,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if is_marker and line_len > pw then
|
||||
|
|
|
|||
|
|
@ -543,11 +543,10 @@ local function compute_highlight_groups(is_default)
|
|||
local normal_fg = normal.fg or (dark and 0xcccccc or 0x333333)
|
||||
|
||||
local alpha = config.highlights.blend_alpha or 0.6
|
||||
local text_alpha = math.min(alpha + 0.3, 1.0)
|
||||
local blended_add = blend_color(add_bg, bg, alpha)
|
||||
local blended_del = blend_color(del_bg, bg, alpha)
|
||||
local blended_add_text = blend_color(add_bg, bg, text_alpha)
|
||||
local blended_del_text = blend_color(del_bg, bg, text_alpha)
|
||||
local blended_add_text = add_bg
|
||||
local blended_del_text = del_bg
|
||||
|
||||
local clear_hl = { default = dflt, fg = normal_fg }
|
||||
if not transparent then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue