fix(pum): pumborder=shadow not blending properly (#37328)

Problem:  Setting pumborder=shadow doesn't blend proerly.
Solution: Check fconfig.shadow when setting pum_grid.blending, like what
          is done in check_blending().
This commit is contained in:
zeertzjq
2026-01-09 19:52:59 +08:00
committed by GitHub
parent 0aabe7ae76
commit 445cb751e6
5 changed files with 25 additions and 54 deletions

View File

@@ -73,8 +73,8 @@ hi('FloatBorder', { link = 'WinSeparator' })
hi('FloatTitle', { link = 'Title' }) hi('FloatTitle', { link = 'Title' })
hi('FloatFooter', { link = 'Title' }) hi('FloatFooter', { link = 'Title' })
hi('FloatShadow', { bg = 'Black', blend=80 }) hi('FloatShadow', { bg = 'Black', blend = 80 })
hi('FloatShadowThrough', { bg = 'Black', blend=100 }) hi('FloatShadowThrough', { bg = 'Black', blend = 100 })
hi('RedrawDebugNormal', { reverse = true, cterm = { reverse = true } }) hi('RedrawDebugNormal', { reverse = true, cterm = { reverse = true } })
hi('RedrawDebugClear', { bg = 'Yellow', ctermbg = 'Yellow' }) hi('RedrawDebugClear', { bg = 'Yellow', ctermbg = 'Yellow' })
hi('RedrawDebugComposed', { bg = 'Green', ctermbg = 'Green' }) hi('RedrawDebugComposed', { bg = 'Green', ctermbg = 'Green' })

View File

@@ -175,6 +175,7 @@ static const char *highlight_init_both[] = {
"default link PmenuKindSel PmenuSel", "default link PmenuKindSel PmenuSel",
"default link PmenuSbar Pmenu", "default link PmenuSbar Pmenu",
"default link PmenuBorder Pmenu", "default link PmenuBorder Pmenu",
"default link PmenuShadow FloatShadow",
"default link PmenuShadowThrough FloatShadowThrough", "default link PmenuShadowThrough FloatShadowThrough",
"default link PreInsert Added", "default link PreInsert Added",
"default link ComplMatchIns NONE", "default link ComplMatchIns NONE",
@@ -381,7 +382,6 @@ static const char *highlight_init_light[] = {
"OkMsg guifg=NvimDarkGreen ctermfg=2", "OkMsg guifg=NvimDarkGreen ctermfg=2",
"Pmenu guibg=NvimLightGrey3 cterm=reverse", "Pmenu guibg=NvimLightGrey3 cterm=reverse",
"PmenuThumb guibg=NvimLightGrey4", "PmenuThumb guibg=NvimLightGrey4",
"PmenuShadow guibg=NvimLightGrey4 ctermbg=0 blend=100",
"Question guifg=NvimDarkCyan ctermfg=6", "Question guifg=NvimDarkCyan ctermfg=6",
"QuickFixLine guifg=NvimDarkCyan ctermfg=6", "QuickFixLine guifg=NvimDarkCyan ctermfg=6",
"RedrawDebugClear guibg=NvimLightYellow ctermfg=15 ctermbg=3", "RedrawDebugClear guibg=NvimLightYellow ctermfg=15 ctermbg=3",
@@ -467,7 +467,6 @@ static const char *highlight_init_dark[] = {
"OkMsg guifg=NvimLightGreen ctermfg=10", "OkMsg guifg=NvimLightGreen ctermfg=10",
"Pmenu guibg=NvimDarkGrey3 cterm=reverse", "Pmenu guibg=NvimDarkGrey3 cterm=reverse",
"PmenuThumb guibg=NvimDarkGrey4", "PmenuThumb guibg=NvimDarkGrey4",
"PmenuShadow guibg=NvimDarkGrey4 ctermbg=0 blend=100",
"Question guifg=NvimLightCyan ctermfg=14", "Question guifg=NvimLightCyan ctermfg=14",
"QuickFixLine guifg=NvimLightCyan ctermfg=14", "QuickFixLine guifg=NvimLightCyan ctermfg=14",
"RedrawDebugClear guibg=NvimDarkYellow ctermfg=0 ctermbg=11", "RedrawDebugClear guibg=NvimDarkYellow ctermfg=0 ctermbg=11",

View File

@@ -2365,7 +2365,6 @@ static const char *did_set_previewwindow(optset_T *args)
static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED) static const char *did_set_pumblend(optset_T *args FUNC_ATTR_UNUSED)
{ {
hl_invalidate_blends(); hl_invalidate_blends();
pum_grid.blending = (p_pb > 0);
if (pum_drawn()) { if (pum_drawn()) {
pum_redraw(); pum_redraw();
} }

View File

@@ -649,6 +649,7 @@ void pum_redraw(void)
col_off++; col_off++;
} }
} }
pum_grid.blending = p_pb > 0 || fconfig.shadow;
grid_assign_handle(&pum_grid); grid_assign_handle(&pum_grid);
pum_left_col = pum_col - col_off; pum_left_col = pum_col - col_off;

View File

@@ -1063,9 +1063,10 @@ describe('builtin popupmenu', function()
[111] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkBlue }, [111] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkBlue },
[112] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkGreen }, [112] = { background = Screen.colors.Plum1, foreground = Screen.colors.DarkGreen },
[113] = { background = Screen.colors.Yellow, foreground = Screen.colors.Black }, [113] = { background = Screen.colors.Yellow, foreground = Screen.colors.Black },
[114] = { background = Screen.colors.Grey0, blend = 100 }, [114] = { background = Screen.colors.Black, blend = 100 },
[115] = { background = Screen.colors.Grey0, blend = 80 }, [115] = { background = Screen.colors.Black, blend = 80 },
[116] = { blend = 100, background = Screen.colors.NvimLightGrey4 }, [116] = { foreground = Screen.colors.Black },
[117] = { background = Screen.colors.Grey80, foreground = Screen.colors.Black },
-- popup non-selected item -- popup non-selected item
n = { background = Screen.colors.Plum1 }, n = { background = Screen.colors.Plum1 },
-- popup scrollbar knob -- popup scrollbar knob
@@ -9221,7 +9222,8 @@ describe('builtin popupmenu', function()
end) end)
it("'pumborder' with shadow", function() it("'pumborder' with shadow", function()
command('set pumborder=shadow') command('set pumborder=shadow')
feed('S<C-x><C-o>') insert('line1\nline2line2line2line2\nline3\nline4line4line4\nline5line5')
feed('ggO<C-x><C-o>')
if multigrid then if multigrid then
screen:expect({ screen:expect({
grid = [[ grid = [[
@@ -9230,16 +9232,21 @@ describe('builtin popupmenu', function()
[3:------------------------------]| [3:------------------------------]|
## grid 2 ## grid 2
one^ | one^ |
{1:~ }|*9 line1 |
line2line2line2line2 |
line3 |
line4line4line4 |
line5line5 |
{1:~ }|*4
## grid 3 ## grid 3
{5:-- }{6:match 1 of 3} | {5:-- }{6:match 1 of 3} |
## grid 4 ## grid 4
{n:1info}| {n:1info}|
## grid 5 ## grid 5
{12:one }{114: }| {12:one }{114: }|
{n:two }{116: }| {n:two }{115: }|
{n:three }{116: }| {n:three }{115: }|
{114: }{116: }| {114: }{115: }|
]], ]],
win_pos = { win_pos = {
[2] = { [2] = {
@@ -9254,51 +9261,16 @@ describe('builtin popupmenu', function()
[5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 }, [5] = { -1, 'NW', 2, 1, 0, false, 100, 2, 1, 0 },
[4] = { 1001, 'NW', 1, 1, 16, false, 50, 1, 1, 16 }, [4] = { 1001, 'NW', 1, 1, 16, false, 50, 1, 1, 16 },
}, },
win_viewport = {
[2] = {
win = 1000,
topline = 0,
botline = 2,
curline = 0,
curcol = 3,
linecount = 1,
sum_scroll_delta = 0,
},
[4] = {
win = 1001,
topline = 0,
botline = 1,
curline = 0,
curcol = 0,
linecount = 1,
sum_scroll_delta = 0,
},
},
win_viewport_margins = {
[2] = {
bottom = 0,
left = 0,
right = 0,
top = 0,
win = 1000,
},
[4] = {
bottom = 0,
left = 0,
right = 0,
top = 0,
win = 1001,
},
},
}) })
else else
screen:expect([[ screen:expect([[
one^ | one^ |
{12:one }{114: }{n:1info}{1: }| {12:one }{116: }{n:1info} |
{n:two }{116: }{1: }| {n:two }{117:l}ine2 |
{n:three }{116: }{1: }| {n:three }{117: } |
{114: }{116: }{1: }| {116:l}{117:ine4line4line4 } |
{1:~ }|*5 line5line5 |
{1:~ }|*4
{5:-- }{6:match 1 of 3} | {5:-- }{6:match 1 of 3} |
]]) ]])
end end