diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-12-18 07:34:52 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-12-18 08:15:31 +0800 |
commit | 2f7b385f2ef61626bc034bd6f3a25f5ec9f3a1f3 (patch) | |
tree | 22fa7d5d9c4621fb3cf9a313bf348a1135fd4c83 | |
parent | c830901e8cde49467d1c99c2d656a13e51979790 (diff) | |
download | rneovim-2f7b385f2ef61626bc034bd6f3a25f5ec9f3a1f3.tar.gz rneovim-2f7b385f2ef61626bc034bd6f3a25f5ec9f3a1f3.tar.bz2 rneovim-2f7b385f2ef61626bc034bd6f3a25f5ec9f3a1f3.zip |
vim-patch:9.1.0941: ComplMatchIns doesn't work after multibyte chars
Problem: ComplMatchIns doesn't work after multibyte chars
(after v9.1.0936)
Solution: Use (ptr - line) instead of wlv.col (zeertzjq).
closes: vim/vim#16233
https://github.com/vim/vim/commit/f4ccada5c372b2c14cc32490860c6995cd00268c
-rw-r--r-- | src/nvim/drawline.c | 27 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 65 | ||||
-rw-r--r-- | test/old/testdir/test_popup.vim | 10 |
3 files changed, 83 insertions, 19 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index e15296572b..a1d03486ff 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -956,7 +956,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s int vi_attr = 0; // attributes for Visual and incsearch highlighting int area_attr = 0; // attributes desired by highlighting int search_attr = 0; // attributes desired by 'hlsearch' - int ins_match_attr = 0; // attributes desired by PmenuMatch int vcol_save_attr = 0; // saved attr for 'cursorcolumn' int decor_attr = 0; // attributes desired by syntax and extmarks bool has_syntax = false; // this buffer has syntax highl. @@ -1632,8 +1631,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s } // When still displaying '$' of change command, stop at cursor. - if (dollar_vcol >= 0 && wp == curwin - && lnum == wp->w_cursor.lnum && wlv.vcol >= wp->w_virtcol) { + if (dollar_vcol >= 0 && in_curline && wlv.vcol >= wp->w_virtcol) { draw_virt_text(wp, buf, win_col_offset, &wlv.col, wlv.row); // don't clear anything after wlv.col wlv_put_linebuf(wp, &wlv, wlv.col, false, bg_attr, 0); @@ -1789,6 +1787,16 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s wlv.char_attr = hl_combine_attr(char_attr_base, char_attr_pri); } + // Apply ComplMatchIns highlight if needed. + if (wlv.filler_todo <= 0 + && (State & MODE_INSERT) && in_curline && ins_compl_active()) { + int ins_match_attr = ins_compl_col_range_attr((int)(ptr - line)); + if (ins_match_attr > 0) { + char_attr_pri = hl_combine_attr(char_attr_pri, ins_match_attr); + wlv.char_attr = hl_combine_attr(char_attr_base, char_attr_pri); + } + } + if (draw_folded && has_foldtext && wlv.n_extra == 0 && wlv.col == win_col_offset) { const int v = (int)(ptr - line); linenr_T lnume = lnum + foldinfo.fi_lines - 1; @@ -2449,8 +2457,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s // With 'virtualedit' we may never reach cursor position, but we still // need to correct the cursor column, so do that at end of line. if (!did_wcol && wlv.filler_todo <= 0 - && wp == curwin && lnum == wp->w_cursor.lnum - && conceal_cursor_line(wp) + && in_curline && conceal_cursor_line(wp) && (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) { wp->w_wcol = wlv.col - wlv.boguscols; if (wlv.vcol + wlv.skip_cells < wp->w_virtcol) { @@ -2643,7 +2650,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s // Update w_cline_height and w_cline_folded if the cursor line was // updated (saves a call to plines_win() later). - if (wp == curwin && lnum == curwin->w_cursor.lnum) { + if (in_curline) { curwin->w_cline_row = startrow; curwin->w_cline_height = wlv.row - startrow; curwin->w_cline_folded = has_fold; @@ -2707,14 +2714,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s vcol_prev = wlv.vcol; } - if (wlv.filler_todo <= 0 - && (State & MODE_INSERT) && in_curline && ins_compl_active()) { - ins_match_attr = ins_compl_col_range_attr(wlv.col); - if (ins_match_attr > 0) { - wlv.char_attr = hl_combine_attr(wlv.char_attr, ins_match_attr); - } - } - // Store character to be displayed. // Skip characters that are left of the screen for 'nowrap'. if (wlv.filler_todo > 0) { diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index beb3ae385c..1d4709e856 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -5561,6 +5561,71 @@ describe('builtin popupmenu', function() ]]) feed('<C-E><ESC>') end) + + -- oldtest: Test_pum_matchins_higlight() + it('with ComplMatchIns highlight', function() + exec([[ + func Omni_test(findstart, base) + if a:findstart + return col(".") + endif + return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] + endfunc + set omnifunc=Omni_test + hi ComplMatchIns guifg=red + ]]) + + feed('Sαβγ <C-X><C-O>') + screen:expect([[ + αβγ {8:foo}^ | + {1:~ }{s: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: 你好 }{1: }| + {1:~ }|*15 + {2:-- }{5:match 1 of 3} | + ]]) + feed('<C-E><Esc>') + + feed('Sαβγ <C-X><C-O><C-N>') + screen:expect([[ + αβγ {8:bar}^ | + {1:~ }{n: foo }{1: }| + {1:~ }{s: bar }{1: }| + {1:~ }{n: 你好 }{1: }| + {1:~ }|*15 + {2:-- }{5:match 2 of 3} | + ]]) + feed('<C-E><Esc>') + + feed('Sαβγ <C-X><C-O><C-N><C-N>') + screen:expect([[ + αβγ {8:你好}^ | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{s: 你好 }{1: }| + {1:~ }|*15 + {2:-- }{5:match 3 of 3} | + ]]) + feed('<C-E><Esc>') + + -- restore after accept + feed('Sαβγ <C-X><C-O><C-Y>') + screen:expect([[ + αβγ foo^ | + {1:~ }|*18 + {2:-- INSERT --} | + ]]) + feed('<Esc>') + + -- restore after cancel completion + feed('Sαβγ <C-X><C-O><Space>') + screen:expect([[ + αβγ foo ^ | + {1:~ }|*18 + {2:-- INSERT --} | + ]]) + feed('<Esc>') + end) end end diff --git a/test/old/testdir/test_popup.vim b/test/old/testdir/test_popup.vim index 4f5b769ace..de8674dad0 100644 --- a/test/old/testdir/test_popup.vim +++ b/test/old/testdir/test_popup.vim @@ -1729,29 +1729,29 @@ func Test_pum_matchins_higlight() let buf = RunVimInTerminal('-S Xscript', {}) call TermWait(buf) - call term_sendkeys(buf, "S\<C-X>\<C-O>") + call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>") call VerifyScreenDump(buf, 'Test_pum_matchins_01', {}) call term_sendkeys(buf, "\<C-E>\<Esc>") call TermWait(buf) - call term_sendkeys(buf, "S\<C-X>\<C-O>\<C-N>") + call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>") call VerifyScreenDump(buf, 'Test_pum_matchins_02', {}) call term_sendkeys(buf, "\<C-E>\<Esc>") call TermWait(buf) - call term_sendkeys(buf, "S\<C-X>\<C-O>\<C-N>\<C-N>") + call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-N>\<C-N>") call VerifyScreenDump(buf, 'Test_pum_matchins_03', {}) call term_sendkeys(buf, "\<C-E>\<Esc>") " restore after accept call TermWait(buf) - call term_sendkeys(buf, "S\<C-X>\<C-O>\<C-Y>") + call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<C-Y>") call VerifyScreenDump(buf, 'Test_pum_matchins_04', {}) call term_sendkeys(buf, "\<C-E>\<Esc>") " restore after cancel completion call TermWait(buf) - call term_sendkeys(buf, "S\<C-X>\<C-O>\<Space>") + call term_sendkeys(buf, "Sαβγ \<C-X>\<C-O>\<Space>") call VerifyScreenDump(buf, 'Test_pum_matchins_05', {}) call term_sendkeys(buf, "\<C-E>\<Esc>") |