]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0496: matched text is highlighted case-sensitively v9.1.0496
authorglepnir <glephunter@gmail.com>
Mon, 17 Jun 2024 16:35:25 +0000 (18:35 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 17 Jun 2024 16:35:25 +0000 (18:35 +0200)
Problem:  matched text is highlighted case-sensitively
Solution: use MB_STRNICMP, update highlighting when the base changes
          (glepnir)

fixes: #15021
closes: #15023

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/insexpand.c
src/popupmenu.c
src/testdir/dumps/Test_pum_highlights_09.dump [new file with mode: 0644]
src/testdir/test_popup.vim
src/version.c

index 28e4d344ed55f0f035a776086a21b201eb8aae80..c673df927c933319dbf9d41e51df610ccb0eff43 100644 (file)
@@ -1448,7 +1448,7 @@ ins_compl_show_pum(void)
     char_u *
 ins_compl_leader(void)
 {
-    return compl_leader;
+    return compl_leader != NULL ? compl_leader : compl_orig_text;
 }
 
 /*
index fdec5f3ec2963f2a2aa1889f4ddf1d7b1986e050..6e9d8264732421af53420c9ed17cab2235a90b2a 100644 (file)
@@ -461,7 +461,7 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf)
     if (in_fuzzy)
        ga = fuzzy_match_str_with_pos(text, leader);
     else
-       matched_start = STRNCMP(text, leader, leader_len) == 0;
+       matched_start = MB_STRNICMP(text, leader, leader_len) == 0;
 
     while (*ptr != NUL)
     {
diff --git a/src/testdir/dumps/Test_pum_highlights_09.dump b/src/testdir/dumps/Test_pum_highlights_09.dump
new file mode 100644 (file)
index 0000000..3616c80
--- /dev/null
@@ -0,0 +1,20 @@
+|f+0&#ffffff0> @73
+|f+0#00e0e07#e0e0e08|o+0#0000001&@1| @11| +0#4040ff13#ffffff0@59
+|F+0#0000e05#ffd7ff255|o+0#0000001&@1|b|a|r| @8| +0#4040ff13#ffffff0@59
+|f+0#0000e05#ffd7ff255|o+0#0000001&@1|B|a|z| @8| +0#4040ff13#ffffff0@59
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@62
index d1fa5a96f8480d2d0cad48c99d311dc62bc4191b..dd01a57da82f41f1ab5f9a96712d60b6d0108f12 100644 (file)
@@ -1400,6 +1400,20 @@ func Test_pum_highlights_match()
             \ { 'word': '你可好吗' },
             \]}
     endfunc
+
+    func Comp()
+      let col = col('.')
+      if getline('.') == 'f'
+        let col -= 1
+      endif
+      call complete(col, [
+            \ #{word: "foo", icase: 1},
+            \ #{word: "Foobar", icase: 1},
+            \ #{word: "fooBaz", icase: 1},
+            \])
+      return ''
+    endfunc
+
     set omnifunc=Omni_test
     set completeopt=menu,noinsert,fuzzy
     hi PmenuMatchSel  ctermfg=6 ctermbg=7
@@ -1463,7 +1477,14 @@ func Test_pum_highlights_match()
     call term_sendkeys(buf, ":set norightleft\<CR>")
   endif
 
+  call term_sendkeys(buf, "S\<C-R>=Comp()\<CR>f")
+  call VerifyScreenDump(buf, 'Test_pum_highlights_09', {})
+  call term_sendkeys(buf, "o\<BS>\<C-R>=Comp()\<CR>")
+  call VerifyScreenDump(buf, 'Test_pum_highlights_09', {})
+
+  call term_sendkeys(buf, "\<C-E>\<Esc>")
   call TermWait(buf)
+
   call StopVimInTerminal(buf)
 endfunc
 
index 356569661359300355a7e6d4110479358d4b17fc..14a5922a9937d91b8a20ea7dee23c03e2e4041ea 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    496,
 /**/
     495,
 /**/