diff --git a/src/nvim/popupmenu.c b/src/nvim/popupmenu.c index bbfe654a99..d79d4b3c43 100644 --- a/src/nvim/popupmenu.c +++ b/src/nvim/popupmenu.c @@ -651,7 +651,9 @@ void pum_redraw(void) for (int i = 0; i < pum_height; i++) { int idx = i + pum_first; - const hlf_T *const hlfs = (idx == pum_selected) ? hlfsSel : hlfsNorm; + const bool selected = idx == pum_selected; + const hlf_T *const hlfs = selected ? hlfsSel : hlfsNorm; + const int trunc_attr = win_hl_attr(curwin, selected ? HLF_PSI : HLF_PNI); hlf_T hlf = hlfs[0]; // start with "word" highlight int attr = win_hl_attr(curwin, (int)hlf); attr = hl_combine_attr(win_hl_attr(curwin, HLF_PNI), attr); @@ -825,6 +827,7 @@ void pum_redraw(void) grid_line_fill(lcol, grid_col + 1, schar_from_ascii(' '), orig_attr); if (need_fcs_trunc) { linebuf_char[lcol] = fcs_trunc != NUL ? fcs_trunc : schar_from_ascii('<'); + linebuf_attr[lcol] = trunc_attr; if (pum_width > 1 && linebuf_char[lcol + 1] == NUL) { linebuf_char[lcol + 1] = schar_from_ascii(' '); } @@ -837,6 +840,7 @@ void pum_redraw(void) linebuf_char[rcol - 2] = schar_from_ascii(' '); } linebuf_char[rcol - 1] = fcs_trunc != NUL ? fcs_trunc : schar_from_ascii('>'); + linebuf_attr[rcol - 1] = trunc_attr; } } diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index b274126b6c..cbef2ac818 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5810,6 +5810,7 @@ describe('builtin popupmenu', function() it("'pummaxwidth' with multibyte", function() screen:try_resize(60, 8) exec([[ + hi StrikeFake guifg=DarkRed let g:change = 0 func Omni_test(findstart, base) if a:findstart @@ -5834,8 +5835,14 @@ describe('builtin popupmenu', function() \ #{word: "bar", menu: "fooMenu", kind: "一二三四"}, \ #{word: "一二三四五", kind: "multi"}, \ ] - else return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] + elseif g:change == 3 + return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] + else + return [ + \ #{word: "一二三四五六七八九十", abbr_hlgroup: "StrikeFake"}, + \ #{word: "123456789_123456789_123456789_", abbr_hlgroup: "StrikeFake"}, + \ ] endif endfunc set omnifunc=Omni_test @@ -6399,6 +6406,36 @@ describe('builtin popupmenu', function() end feed('') command('set norightleft') + + command('let g:change=4') + feed('S') + if multigrid then + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*19 + [3:--------------------------------]| + ## grid 2 + 一二三四五六七八九十^ | + {1:~ }|*18 + ## grid 3 + {2:-- }{5:match 1 of 2} | + ## grid 4 + {ds:一二三四五六七 }{s:>}| + {dn:123456789_12345}{n:>}| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 0, false, 100, 1, 1, 0 } }, + }) + else + screen:expect([[ + 一二三四五六七八九十^ | + {ds:一二三四五六七 }{s:>}{1: }| + {dn:123456789_12345}{n:>}{1: }| + {1:~ }|*16 + {2:-- }{5:match 1 of 2} | + ]]) + end + feed('') end) it('does not crash when displayed in last column with rightleft #12032', function() diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim index 8f65d768ce..8a6243773a 100644 --- a/test/old/testdir/test_popup.vim +++ b/test/old/testdir/test_popup.vim @@ -2036,6 +2036,7 @@ func Test_pum_maxwidth_multibyte() CheckScreendump let lines =<< trim END + hi StrikeFake ctermfg=9 let g:change = 0 func Omni_test(findstart, base) if a:findstart @@ -2060,8 +2061,14 @@ func Test_pum_maxwidth_multibyte() \ #{word: "bar", menu: "fooMenu", kind: "一二三四"}, \ #{word: "一二三四五", kind: "multi"}, \ ] - else return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] + elseif g:change == 3 + return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] + else + return [ + \ #{word: "一二三四五六七八九十", abbr_hlgroup: "StrikeFake"}, + \ #{word: "123456789_123456789_123456789_", abbr_hlgroup: "StrikeFake"}, + \ ] endif endfunc set omnifunc=Omni_test @@ -2174,6 +2181,12 @@ func Test_pum_maxwidth_multibyte() call term_sendkeys(buf, "\:set norightleft\") endif + call term_sendkeys(buf, ":let g:change=4\") + call TermWait(buf, 50) + call term_sendkeys(buf, "S\\") + call VerifyScreenDump(buf, 'Test_pum_maxwidth_23', {'rows': 8}) + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) endfunc