mirror of
https://github.com/neovim/neovim.git
synced 2026-04-20 14:25:32 +00:00
fix(highlight): Normal-linked groups shouldn't override CursorLine #35026
Problem: CursorLine doesn't consistently highlight text using groups linked to Normal (e.g., in quickfix, passwd files), while it works for direct Normal usage. Solution: Don't let normal background from linked groups override explicit non-normal backgrounds during attribute combination.
This commit is contained in:
@@ -2924,7 +2924,25 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b
|
|||||||
|
|
||||||
if (wlv.filler_todo <= 0) {
|
if (wlv.filler_todo <= 0) {
|
||||||
// Apply lowest-priority line attr now, so everything can override it.
|
// Apply lowest-priority line attr now, so everything can override it.
|
||||||
wlv.char_attr = hl_combine_attr(wlv.line_attr_lowprio, wlv.char_attr);
|
int low = wlv.line_attr_lowprio;
|
||||||
|
int high = wlv.char_attr;
|
||||||
|
|
||||||
|
if (wlv.line_attr_lowprio != 0) {
|
||||||
|
HlAttrs line_ae = syn_attr2entry(wlv.line_attr_lowprio);
|
||||||
|
HlAttrs char_ae = syn_attr2entry(wlv.char_attr);
|
||||||
|
// If line has background (CursorLine) and char's background equals Normal's background,
|
||||||
|
// reverse the combination order to let CursorLine override normal_bg.
|
||||||
|
bool has_line_bg = line_ae.rgb_bg_color >= 0 || line_ae.cterm_bg_color > 0;
|
||||||
|
bool char_is_normal_bg = ui_rgb_attached()
|
||||||
|
? (char_ae.rgb_bg_color == normal_bg)
|
||||||
|
: (char_ae.cterm_bg_color == cterm_normal_bg_color);
|
||||||
|
|
||||||
|
if (has_line_bg && char_is_normal_bg) {
|
||||||
|
low = wlv.char_attr;
|
||||||
|
high = wlv.line_attr_lowprio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wlv.char_attr = hl_combine_attr(low, high);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlv.filler_todo <= 0) {
|
if (wlv.filler_todo <= 0) {
|
||||||
|
|||||||
@@ -1378,6 +1378,23 @@ describe('CursorLine and CursorLineNr highlights', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('CursorLine overlays hl group linked to Normal', function()
|
||||||
|
local screen = Screen.new(50, 12)
|
||||||
|
screen:add_extra_attr_ids({
|
||||||
|
[101] = { background = Screen.colors.Grey90, foreground = Screen.colors.Gray100 },
|
||||||
|
})
|
||||||
|
command('hi Normal guibg=black guifg=white')
|
||||||
|
command('hi def link Test Normal')
|
||||||
|
feed('ifoo bar<ESC>')
|
||||||
|
feed(':call matchadd("Test", "bar")<cr>')
|
||||||
|
command('set cursorline')
|
||||||
|
screen:expect([[
|
||||||
|
{21:foo }{101:ba^r}{21: }|
|
||||||
|
{1:~ }|*10
|
||||||
|
:call matchadd("Test", "bar") |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('CursorColumn highlight', function()
|
describe('CursorColumn highlight', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user