patch 9.1.0941: ComplMatchIns doesn't work after multibyte chars

Commit: 
https://github.com/vim/vim/commit/f4ccada5c372b2c14cc32490860c6995cd00268c
Author: zeertzjq <zeert...@outlook.com>
Date:   Tue Dec 17 20:50:19 2024 +0100

    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: #16233
    
    Signed-off-by: zeertzjq <zeert...@outlook.com>
    Signed-off-by: glepnir <glephun...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/drawline.c b/src/drawline.c
index ec9133103..18857ee2e 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1173,7 +1173,6 @@ win_line(
                                        // 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
 #ifdef FEAT_SYN_HL
     int                vcol_save_attr = 0;     // saved attr for 'cursorcolumn'
     int                syntax_attr = 0;        // attributes desired by syntax
@@ -2012,9 +2011,7 @@ win_line(
 #endif
 
        // When still displaying '$' of change command, stop at cursor.
-       if (dollar_vcol >= 0 && wp == curwin
-               && lnum == wp->w_cursor.lnum
-               && wlv.vcol >= (long)wp->w_virtcol)
+       if (dollar_vcol >= 0 && in_curline && wlv.vcol >= (long)wp->w_virtcol)
        {
            wlv_screen_line(wp, &wlv, FALSE);
            // Pretend we have finished updating the window.  Except when
@@ -2565,6 +2562,15 @@ win_line(
 #endif
        }
 
+       // Apply ComplMatchIns highlight if needed.
+       if (wlv.draw_state == WL_LINE
+               && (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)
+               wlv.char_attr = hl_combine_attr(wlv.char_attr, ins_match_attr);
+       }
+
        // combine attribute with 'wincolor'
        if (wlv.win_attr != 0)
        {
@@ -3608,8 +3614,7 @@ win_line(
        // 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.draw_state == WL_LINE
-               && wp == curwin && lnum == wp->w_cursor.lnum
-               && conceal_cursor_line(wp)
+               && in_curline && conceal_cursor_line(wp)
                && (wlv.vcol + skip_cells >= wp->w_virtcol || c == NUL))
        {
 # ifdef FEAT_RIGHTLEFT
@@ -3850,7 +3855,7 @@ win_line(
 
                // Update w_cline_height and w_cline_folded if the cursor line
                // was updated (saves a call to plines() later).
-               if (wp == curwin && lnum == curwin->w_cursor.lnum)
+               if (in_curline)
                {
                    curwin->w_cline_row = startrow;
                    curwin->w_cline_height = wlv.row - startrow;
@@ -3940,14 +3945,6 @@ win_line(
        if (wlv.draw_state == WL_LINE)
            vcol_prev = wlv.vcol;
 
-       if (wlv.draw_state == WL_LINE
-               && (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.draw_state < WL_LINE || skip_cells <= 0)
diff --git a/src/testdir/dumps/Test_pum_matchins_01.dump 
b/src/testdir/dumps/Test_pum_matchins_01.dump
index efaa1eb0c..9eb47ac48 100644
--- a/src/testdir/dumps/Test_pum_matchins_01.dump
+++ b/src/testdir/dumps/Test_pum_matchins_01.dump
@@ -1,7 +1,7 @@
-|f+0#ff404010#ffffff0|o@1> +0#0000000&@71
-|f+0#0000001#e0e0e08|o@1| @11| +0#4040ff13#ffffff0@59
-|b+0#0000001#ffd7ff255|a|r| @11| +0#4040ff13#ffffff0@59
-|你*0#0000001#ffd7ff255|好| +&@10| +0#4040ff13#ffffff0@59
+|α+0&#ffffff0|β|γ| |f+0#ff404010&|o@1> +0#0000000&@67
+|~+0#4040ff13&| @1| +0#0000001#e0e0e08|f|o@1| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#ffd7ff255|b|a|r| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#ffd7ff255|你*&|好| +&@10| +0#4040ff13#ffffff0@55
 |~| @73
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_pum_matchins_02.dump 
b/src/testdir/dumps/Test_pum_matchins_02.dump
index a3d9be31c..a9e7258f5 100644
--- a/src/testdir/dumps/Test_pum_matchins_02.dump
+++ b/src/testdir/dumps/Test_pum_matchins_02.dump
@@ -1,7 +1,7 @@
-|b+0#ff404010#ffffff0|a|r> +0#0000000&@71
-|f+0#0000001#ffd7ff255|o@1| @11| +0#4040ff13#ffffff0@59
-|b+0#0000001#e0e0e08|a|r| @11| +0#4040ff13#ffffff0@59
-|你*0#0000001#ffd7ff255|好| +&@10| +0#4040ff13#ffffff0@59
+|α+0&#ffffff0|β|γ| |b+0#ff404010&|a|r> +0#0000000&@67
+|~+0#4040ff13&| @1| +0#0000001#ffd7ff255|f|o@1| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#e0e0e08|b|a|r| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#ffd7ff255|你*&|好| +&@10| +0#4040ff13#ffffff0@55
 |~| @73
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_pum_matchins_03.dump 
b/src/testdir/dumps/Test_pum_matchins_03.dump
index d1686b7e0..b8aaffe2b 100644
--- a/src/testdir/dumps/Test_pum_matchins_03.dump
+++ b/src/testdir/dumps/Test_pum_matchins_03.dump
@@ -1,7 +1,7 @@
-|你*0#ff404010#ffffff0|好> +0#0000000&@70
-|f+0#0000001#ffd7ff255|o@1| @11| +0#4040ff13#ffffff0@59
-|b+0#0000001#ffd7ff255|a|r| @11| +0#4040ff13#ffffff0@59
-|你*0#0000001#e0e0e08|好| +&@10| +0#4040ff13#ffffff0@59
+|α+0&#ffffff0|β|γ| |你*0#ff404010&|好> +0#0000000&@66
+|~+0#4040ff13&| @1| +0#0000001#ffd7ff255|f|o@1| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#ffd7ff255|b|a|r| @11| +0#4040ff13#ffffff0@55
+|~| @1| +0#0000001#e0e0e08|你*&|好| +&@10| +0#4040ff13#ffffff0@55
 |~| @73
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_pum_matchins_04.dump 
b/src/testdir/dumps/Test_pum_matchins_04.dump
index 0a324ef17..ced268e99 100644
--- a/src/testdir/dumps/Test_pum_matchins_04.dump
+++ b/src/testdir/dumps/Test_pum_matchins_04.dump
@@ -1,4 +1,4 @@
-|f+0&#ffffff0|o@1> @71
+|α+0&#ffffff0|β|γ| |f|o@1> @67
 |~+0#4040ff13&| @73
 |~| @73
 |~| @73
@@ -17,4 +17,4 @@
 |~| @73
 |~| @73
 |~| @73
-|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|4| @10|A|l@1| 
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|1@1|-|8| @7|A|l@1| 
diff --git a/src/testdir/dumps/Test_pum_matchins_05.dump 
b/src/testdir/dumps/Test_pum_matchins_05.dump
index a799fcd75..af49de217 100644
--- a/src/testdir/dumps/Test_pum_matchins_05.dump
+++ b/src/testdir/dumps/Test_pum_matchins_05.dump
@@ -1,4 +1,4 @@
-|f+0&#ffffff0|o@1| > @70
+|α+0&#ffffff0|β|γ| |f|o@1| > @66
 |~+0#4040ff13&| @73
 |~| @73
 |~| @73
@@ -17,4 +17,4 @@
 |~| @73
 |~| @73
 |~| @73
-|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|5| @10|A|l@1| 
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|1|2|-|9| @7|A|l@1| 
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index bd369574f..95ce56114 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -1728,29 +1728,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>")
 
diff --git a/src/version.c b/src/version.c
index 6a5e976b0..94d4aa885 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    941,
 /**/
     940,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tNdjh-0038qO-0r%40256bit.org.

Raspunde prin e-mail lui