]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1594: completion: search completion throws errors v9.1.1594
authorGirish Palya <girishji@gmail.com>
Wed, 6 Aug 2025 15:12:14 +0000 (17:12 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 6 Aug 2025 15:12:14 +0000 (17:12 +0200)
Problem:  completion: search completion throws errors, wrong placement
          of pum menu with 'imi'=1 (berggeist)
Solution: Fix those errors (Girish Palya)

fixes: #17858
closes: #17870

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/popupmenu.c
src/testdir/dumps/Test_search_wildmenu_iminsert.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index bddfe8ca6a56e6c097fac99982acf232967e7ec3..9d66b0378c26df2ab49e9150626b8321552dc2ce 100644 (file)
@@ -4789,17 +4789,29 @@ copy_substring_from_pos(pos_T *start, pos_T *end, char_u **match,
     static int
 is_regex_match(char_u *pat, char_u *str)
 {
+    if (STRCMP(pat, str) == 0)
+       return TRUE;
+
     regmatch_T regmatch;
     int                result;
 
+    ++emsg_off;
+    ++msg_silent;
     regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
+    --emsg_off;
+    --msg_silent;
+
     if (regmatch.regprog == NULL)
        return FALSE;
     regmatch.rm_ic = p_ic;
     if (p_ic && p_scs)
        regmatch.rm_ic = !pat_has_uppercase(pat);
 
+    ++emsg_off;
+    ++msg_silent;
     result = vim_regexec_nl(&regmatch, str, (colnr_T)0);
+    --emsg_off;
+    --msg_silent;
 
     vim_regfree(regmatch.regprog);
     return result;
index fa6d9a51829f906408746c1035a867465f646579..9456faae3f99b77ad239f44add8412afea6504be 100644 (file)
@@ -109,7 +109,7 @@ pum_display(
 #endif
 
 #ifdef FEAT_RIGHTLEFT
-    pum_rl = State != MODE_CMDLINE && curwin->w_p_rl;
+    pum_rl = (State & MODE_CMDLINE) == 0 && curwin->w_p_rl;
 #endif
 
     do
@@ -129,7 +129,7 @@ pum_display(
        // Remember the essential parts of the window position and size, so we
        // can decide when to reposition the popup menu.
        pum_window = curwin;
-       if (State == MODE_CMDLINE)
+       if (State & MODE_CMDLINE)
            // cmdline completion popup menu
            pum_win_row = cmdline_row;
        else
@@ -165,7 +165,7 @@ pum_display(
                      && pum_win_row - above_row > (below_row - above_row) / 2)
        {
            // pum above "pum_win_row"
-           if (State == MODE_CMDLINE)
+           if (State & MODE_CMDLINE)
                // for cmdline pum, no need for context lines
                context_lines = 0;
            else
@@ -191,7 +191,7 @@ pum_display(
        else
        {
            // pum below "pum_win_row"
-           if (State == MODE_CMDLINE)
+           if (State & MODE_CMDLINE)
                // for cmdline pum, no need for context lines
                context_lines = 0;
            else
@@ -230,7 +230,7 @@ pum_display(
            max_width = p_pmw;
 
        // Calculate column
-       if (State == MODE_CMDLINE)
+       if (State & MODE_CMDLINE)
            // cmdline completion popup menu
            cursor_col = cmdline_compl_startcol();
        else
@@ -440,7 +440,7 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
        return NULL;
 
     is_select = hlf == HLF_PSI;
-    leader = State == MODE_CMDLINE ? cmdline_compl_pattern()
+    leader = (State & MODE_CMDLINE) ? cmdline_compl_pattern()
                                                          : ins_compl_leader();
     if (leader == NULL || *leader == NUL)
        return NULL;
@@ -449,7 +449,7 @@ pum_compute_text_attrs(char_u *text, hlf_T hlf, int user_hlattr)
     if (attrs == NULL)
        return NULL;
 
-    in_fuzzy = State == MODE_CMDLINE ? cmdline_compl_is_fuzzy()
+    in_fuzzy = (State & MODE_CMDLINE) ? cmdline_compl_is_fuzzy()
                                          : (get_cot_flags() & COT_FUZZY) != 0;
     leader_len = STRLEN(leader);
 
diff --git a/src/testdir/dumps/Test_search_wildmenu_iminsert.dump b/src/testdir/dumps/Test_search_wildmenu_iminsert.dump
new file mode 100644 (file)
index 0000000..a7dfb45
--- /dev/null
@@ -0,0 +1,20 @@
+| +0#0000001#e0e0e08|g|l|o|b|a|l| @8| +0#0000000#0000001|e+0&#ffffff0|s@1|:| |c|y|c|l|e| |f|u|l@1| |m|a|t|c|h|e|s| @34
+| +0#0000001#ffd7ff255|g|l|e| @11| +0#0000000#0000001|s+0#0000e05#ffffff0|e|t| |w|i|l|d|m|o|d|e|=|n|o|s|e|l|e|c|t|:|l|a|s|t|u|s|e|d|,|f|u|l@1| +0#0000000&@22
+| +0#0000001#ffd7ff255|g|l|o|b|a|l|-|l|o|c|a|l| @2| +0#0000000#0000001|b+0&#ffffff0|o|v|e|,| |b|u|t| |b|u|f@1|e|r| |m|a|t|c|h|e|s| |a|r|e| |s|o|r|t|e|d| |b|y| |t|i|m|e| |l|a|s|t| |u|s|e|d| @4
+| +0#0000001#ffd7ff255|g|l|o|b|a|l|/|l|o|c|a|l| @2| +0#0000000#0000001| +0&#ffffff0|h|e|r|e|:| |c+0#00e0e07&|m|d|l|i|n|e|-|c|o|m|p|l|e|t|i|o|n|.+0#0000000&| @31
+| +0#0000001#ffd7ff255|g|l|y|p|h|s| @8| +0#0000000#0000001| +0&#ffffff0@57
+| +0#0000001#ffd7ff255|g|l|e|s| @10| +0#0000000#0000001| +0&#ffffff0@30|'+0#e000002&|w|i|l|d|o|p|t|i|o|n|s|'| +0#0000000&|'+0#e000002&|w|o|p|'| +0#0000000&@7
+| +0#0000001#ffd7ff255|g|l|i|s|h| @9| +0#0000000#0000001|p+0#00e0003#ffffff0|'| +0#0000000&@4|s|t|r|i|n|g| @1|(|d|e|f|a|u|l|t| |"@1|)| @30
+| +0#0000001#ffd7ff255|g|l|y|.| @10| +0#0000000#0000001| +0&#ffffff0@6|g|l|o|b|a|l| @44
+| +0#0000001#ffd7ff255|g|l|e|d| @10| +0#0000000#0000001| +0&#ffffff0|w|o|r|d|s| |t|h|a|t| |c|h|a|n|g|e| |h|o|w| |c+0#00e0e07&|m|d|l|i|n|e|-|c|o|m|p|l|e|t|i|o|n| +0#0000000&|i|s| |d|o|n|e|.| @7
+| +0#0000001#ffd7ff255|g|l|y| @11| +0#0000000#0000001| +0&#ffffff0@57
+| +0#0000001#ffd7ff255|g|l|e|-|b|y|t|e| @6| +0#0000000#0000001|w+0&#ffffff0|i|n|g| |v|a|l|u|e|s| |a|r|e| |s|u|p@1|o|r|t|e|d|:| @31
+| +0#0000001#ffd7ff255|g|l|o|b|(|)| @8| +0#0000000#0000001|x+0&#ffffff0|t| @4|W|h|e|n| |t|h|i|s| |f|l|a|g| |i|s| |p|r|e|s|e|n|t|,| |s|e|a|r|c|h| |p|a|t@1|e|r|n| |c|o|m|p|l|e|t|i|o
+| +0#0000001#ffd7ff255|g|l|o|b|(|p|a|t|,| @5| +0#0000000#a8a8a8255| +0&#ffffff0@57
+| +0#0000001#ffd7ff255|g|l|i|s|h|,| @8| +0#0000000#a8a8a8255| +0&#ffffff0@6|(|e|.|g|.|,| |i|n| |/+0#00e0e07&|,+0#0000000&| |?+0#00e0e07&|,+0#0000000&| |:+0#00e0e07&|s|,+0#0000000&| |:+0#00e0e07&|g|,+0#0000000&| |:+0#00e0e07&|v|,+0#0000000&| |a|n|d| |:+0#00e0e07&|v|i|m|)+0#0000000&| @13
+| +0#0000001#ffd7ff255|g|l|i|'| @10| +0#0000000#a8a8a8255| +0&#ffffff0@6|s|h|o|w|s| |e|x|a|c|t| |b|u|f@1|e|r| |t|e|x|t| |a|s| |m|e|n|u| |i|t|e|m|s|,| |w|i|t|h|o|u|t| @4
+| +0#0000001#ffd7ff255|g|l|o|b|a|l|-|i|m|e| @4| +0#0000000#a8a8a8255| +0&#ffffff0@6|p|r|e|s|e|r|v|i|n|g| |r|e|g|e|x| |a|r|t|i|f|a|c|t|s| |l|i|k|e| |p|o|s|i|t|i|o|n| @10
+| +0#0000001#ffd7ff255|g|l|e|-|r|e|p|e|a|t| @4| +0#0000000#a8a8a8255|]+3&#ffffff0|[|R|O|]| @27|<|l|a|n|g|>| |9@1|7|2|,|7|-|4|9| @5|9|7|%
+| +0#0000001#ffd7ff255|g|l|e|'| @10| +0#0000000#a8a8a8255| +0&#ffffff0@57
+| +0#0000001#ffd7ff255|g|l|e|'|.| @9| +0#0000000#a8a8a8255| +1&#ffffff0@32|<|l|a|n|g|>| |0|,|0|-|1| @9|A|l@1
+|/+0&&|g|l|o|b|a|l> @67
index 4e4d34caa6378496c299c2a0e42346184c8550c9..0fe4884996787854b66437863d1d9974de320d2d 100644 (file)
@@ -4564,11 +4564,19 @@ func Test_search_complete()
   call feedkeys("gg/r\\n.*\\n\<tab>\<f9>", 'tx')
   call assert_equal(['r\nFoobar\nfooBAr', 'r\nfooBAr\nFooBARR'], g:compl_info.matches)
 
+  " Issue #17858
+  %d
+  set wildcharm=0 incsearch& ignorecase& smartcase& wildoptions&
+  setlocal iskeyword=!-~,192-255
+  let l:lines = ['th=~/foo', 'these', 'tho']
+  call setline(1, l:lines)
+  call feedkeys("G/th\<tab>\<f9>", 'tx')
+  call assert_equal(l:lines, g:compl_info.matches)
+
   bw!
   call test_override("char_avail", 0)
   delfunc GetComplInfo
   unlet! g:compl_info
-  set wildcharm=0 incsearch& ignorecase& smartcase& wildoptions&
 endfunc
 
 func Test_search_wildmenu_screendump()
@@ -4619,6 +4627,25 @@ func Test_search_wildmenu_screendump()
   call StopVimInTerminal(buf)
 endfunc
 
+" Issue #17858
+func Test_search_wildmenu_iminsert()
+  CheckScreendump
+
+  let lines =<< trim [SCRIPT]
+    set wop=pum imi=1
+    h wildoptions
+  [SCRIPT]
+  call writefile(lines, 'XTest_search_wildmenu', 'D')
+  let buf = RunVimInTerminal('-S XTest_search_wildmenu', {'rows': 20})
+
+  call term_sendkeys(buf, "/gl\<Tab>")
+  call TermWait(buf, 50)
+  call VerifyScreenDump(buf, 'Test_search_wildmenu_iminsert', {})
+
+  call term_sendkeys(buf, "\<esc>")
+  call StopVimInTerminal(buf)
+endfunc
+
 " Test wildcharm completion for :s and :g with range
 func Test_range_complete()
   set wildcharm=<c-z>
index ea483004f2bbdb6f455f11fe32b665861b0b0a57..307b358416b72575c1333c4bd4402795ffe1fc96 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1594,
 /**/
     1593,
 /**/