diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index 529d65c5dc..7df6a1a5d7 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -657,11 +657,14 @@ void pum_redraw(void) pum_align_order(order); int basic_width = items_width_array[order[0]]; // first item width bool last_isabbr = order[2] == CPT_ABBR; + int orig_attr = -1; + for (int j = 0; j < 3; j++) { int item_type = order[j]; hlf = hlfs[item_type]; attr = win_hl_attr(curwin, (int)hlf); - int orig_attr = attr; + attr = hl_combine_attr(win_hl_attr(curwin, HLF_PNI), attr); + orig_attr = attr; int user_abbr_hlattr = pum_array[idx].pum_user_abbr_hlattr; int user_kind_hlattr = pum_array[idx].pum_user_kind_hlattr; if (item_type == CPT_ABBR && user_abbr_hlattr > 0) { @@ -670,7 +673,6 @@ void pum_redraw(void) if (item_type == CPT_KIND && user_kind_hlattr > 0) { attr = hl_combine_attr(attr, user_kind_hlattr); } - attr = hl_combine_attr(win_hl_attr(curwin, HLF_PNI), attr); int width = 0; char *s = NULL; p = pum_get_item(idx, item_type); @@ -796,9 +798,9 @@ void pum_redraw(void) } if (pum_rl) { - grid_line_fill(col_off - pum_width + 1, grid_col + 1, schar_from_ascii(' '), attr); + grid_line_fill(col_off - pum_width + 1, grid_col + 1, schar_from_ascii(' '), orig_attr); } else { - grid_line_fill(grid_col, col_off + pum_width, schar_from_ascii(' '), attr); + grid_line_fill(grid_col, col_off + pum_width, schar_from_ascii(' '), orig_attr); } if (pum_scrollbar > 0) { diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 295d677aa0..d096311703 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5190,10 +5190,18 @@ describe('builtin popupmenu', function() -- oldtest: Test_pum_user_abbr_hlgroup() it('custom abbr_hlgroup override', function() exec([[ - func CompleteFunc( findstart, base ) + let s:var = 0 + func CompleteFunc(findstart, base) if a:findstart return 0 endif + if s:var == 1 + return { + \ 'words': [ + \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' }, + \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' }, + \]} + endif return { \ 'words': [ \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, @@ -5201,6 +5209,9 @@ describe('builtin popupmenu', function() \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, \]} endfunc + func ChangeVar() + let s:var = 1 + endfunc set completeopt=menu set completefunc=CompleteFunc @@ -5243,6 +5254,17 @@ describe('builtin popupmenu', function() {2:-- }{5:match 2 of 3} | ]]) feed('') + + command('call ChangeVar()') + feed('S') + screen:expect([[ + aword1^ | + {ds:aword1}{s: }{1: }| + {dn:你好}{n: }{1: }| + {1:~ }|*16 + {2:-- }{5:match 1 of 2} | + ]]) + feed('') end) -- oldtest: Test_pum_user_kind_hlgroup() diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim index d35d32b13d..601ba6c688 100644 --- a/test/old/testdir/test_popup.vim +++ b/test/old/testdir/test_popup.vim @@ -1509,10 +1509,18 @@ endfunc func Test_pum_user_abbr_hlgroup() CheckScreendump let lines =<< trim END - func CompleteFunc( findstart, base ) + let s:var = 0 + func CompleteFunc(findstart, base) if a:findstart return 0 endif + if s:var == 1 + return { + \ 'words': [ + \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' }, + \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' }, + \]} + endif return { \ 'words': [ \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, @@ -1520,6 +1528,9 @@ func Test_pum_user_abbr_hlgroup() \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, \]} endfunc + func ChangeVar() + let s:var = 1 + endfunc set completeopt=menu set completefunc=CompleteFunc @@ -1547,13 +1558,20 @@ func Test_pum_user_abbr_hlgroup() call VerifyScreenDump(buf, 'Test_pum_highlights_14', {}) call term_sendkeys(buf, "\\") + call TermWait(buf) + call term_sendkeys(buf, ":call ChangeVar()\") + call TermWait(buf) + call term_sendkeys(buf, "S\\") + call VerifyScreenDump(buf, 'Test_pum_highlights_17', {}) + call term_sendkeys(buf, "\\") + call StopVimInTerminal(buf) endfunc func Test_pum_user_kind_hlgroup() CheckScreendump let lines =<< trim END - func CompleteFunc( findstart, base ) + func CompleteFunc(findstart, base) if a:findstart return 0 endif