Skip to content

Commit 6c3e170

Browse files
authored
fix(highlight): apply 'winblend' to float border (neovim#25981)
1 parent fdaf6bc commit 6c3e170

File tree

3 files changed

+69
-9
lines changed

3 files changed

+69
-9
lines changed

src/nvim/highlight.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,15 @@ void update_window_hl(win_T *wp, bool invalid)
374374
if (wp->w_float_config.border_hl_ids[i]) {
375375
attr = hl_get_ui_attr(ns_id, HLF_BORDER,
376376
wp->w_float_config.border_hl_ids[i], false);
377-
HlAttrs a = syn_attr2entry(attr);
378-
if (a.hl_blend) {
379-
wp->w_float_config.shadow = true;
380-
}
377+
}
378+
HlAttrs a = syn_attr2entry(attr);
379+
if (a.hl_blend == -1 && wp->w_p_winbl > 0) {
380+
HlEntry entry = attr_entry(attr);
381+
a.hl_blend = entry.attr.hl_blend = (int)wp->w_p_winbl;
382+
attr = get_attr_entry(entry);
383+
}
384+
if (a.hl_blend > 0) {
385+
wp->w_float_config.shadow = true;
381386
}
382387
wp->w_float_config.border_attr[i] = attr;
383388
}

src/nvim/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,7 @@ static const char *did_set_winblend(optset_T *args)
26862686
if (value != old_value) {
26872687
win->w_p_winbl = MAX(MIN(win->w_p_winbl, 100), 0);
26882688
win->w_hl_needs_update = true;
2689-
check_blending(curwin);
2689+
check_blending(win);
26902690
}
26912691

26922692
return NULL;

test/functional/ui/float_spec.lua

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ describe('float window', function()
10171017
{1: }|
10181018
{2:~ }|
10191019
]], float_pos={
1020-
[5] = {{id = 1002}, "NW", 4, 2, 10, true, 50};
1020+
[5] = {{id = 1002}, "NW", 4, 2, 10, true};
10211021
}}
10221022
else
10231023
screen:expect([[
@@ -9191,6 +9191,13 @@ describe('float window', function()
91919191
[13] = {background = Screen.colors.LightGray, blend = 30},
91929192
[14] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey88},
91939193
[15] = {foreground = tonumber('0x939393'), background = Screen.colors.Grey88},
9194+
[16] = {background = Screen.colors.Grey90};
9195+
[17] = {blend = 100};
9196+
[18] = {background = Screen.colors.LightMagenta, blend = 100};
9197+
[19] = {background = Screen.colors.LightMagenta, bold = true, blend = 100, foreground = Screen.colors.Blue1};
9198+
[20] = {background = Screen.colors.White, foreground = Screen.colors.Gray0};
9199+
[21] = {background = Screen.colors.White, bold = true, foreground = tonumber('0x00007f')};
9200+
[22] = {background = Screen.colors.Gray90, foreground = Screen.colors.Gray0};
91949201
})
91959202
insert([[
91969203
Lorem ipsum dolor sit amet, consectetur
@@ -9321,9 +9328,7 @@ describe('float window', function()
93219328
{13:test }|
93229329
{13: }|
93239330
{13:popup text }|
9324-
]], float_pos={
9325-
[4] = {{id = 1001}, "NW", 1, 2, 5, true, 50};
9326-
}}
9331+
]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}}
93279332
else
93289333
screen:expect([[
93299334
Ut enim ad minim veniam, quis nostrud |
@@ -9477,6 +9482,56 @@ describe('float window', function()
94779482
|
94789483
]])
94799484
end
9485+
9486+
-- Check that 'winblend' applies to border
9487+
meths.win_set_config(win, {border='single'})
9488+
meths.set_option_value('winblend', 100, {win=win.id})
9489+
meths.set_option_value("cursorline", true, {win=0})
9490+
command('hi clear VertSplit')
9491+
feed('k0')
9492+
if multigrid then
9493+
screen:expect{grid=[[
9494+
## grid 1
9495+
[2:--------------------------------------------------]|
9496+
[2:--------------------------------------------------]|
9497+
[2:--------------------------------------------------]|
9498+
[2:--------------------------------------------------]|
9499+
[2:--------------------------------------------------]|
9500+
[2:--------------------------------------------------]|
9501+
[2:--------------------------------------------------]|
9502+
[2:--------------------------------------------------]|
9503+
[3:--------------------------------------------------]|
9504+
## grid 2
9505+
Ut enim ad minim veniam, quis nostrud |
9506+
exercitation ullamco laboris nisi ut aliquip ex |
9507+
ea commodo consequat. Duis aute irure dolor in |
9508+
reprehenderit in voluptate velit esse cillum |
9509+
dolore eu fugiat nulla pariatur. Excepteur sint |
9510+
occaecat cupidatat non proident, sunt in culpa |
9511+
{16:^qui officia deserunt mollit anim id est }|
9512+
laborum. |
9513+
## grid 3
9514+
|
9515+
## grid 4
9516+
{17:┌───────────────┐}|
9517+
{17:│}{11:popup text}{18: }{17:│}|
9518+
{17:│}{19:~ }{17:│}|
9519+
{17:│}{19:~ }{17:│}|
9520+
{17:└───────────────┘}|
9521+
]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}}
9522+
else
9523+
screen:expect([[
9524+
Ut enim ad minim veniam, quis nostrud |
9525+
exercitation ullamco laboris nisi ut aliquip ex |
9526+
ea co{20:┌───────────────┐}Duis aute irure dolor in |
9527+
repre{20:│}{5:popup}{6:it i}{5:text}{20:lu│}tate velit esse cillum |
9528+
dolor{20:│}{21:~}{20:eu fugiat null│} pariatur. Excepteur sint |
9529+
occae{20:│}{21:~}{20:t cupidatat no│} proident, sunt in culpa |
9530+
{16:^qui o}{22:└───────────────┘}{16:ollit anim id est }|
9531+
laborum. |
9532+
|
9533+
]])
9534+
end
94809535
end)
94819536

94829537
it('can overlap doublewidth chars', function()

0 commit comments

Comments
 (0)