]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1528: completion: crash with getcompletion() v9.1.1528
authorChristian Brabandt <cb@256bit.org>
Tue, 8 Jul 2025 20:04:10 +0000 (22:04 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 8 Jul 2025 20:12:37 +0000 (22:12 +0200)
Problem:  completion: crash with getcompletion()
          (zeertzjq)
Solution: Don't set may_expand_pattern in f_getcompletion(),
          unset may_expand_pattern() once it is not longer needed
          (Girish Palya).

fixes: #17680
closes: #17686

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/testdir/test_cmdline.vim
src/version.c

index 75efe1c6236e88cf2c00328ea4273a4ecbe5222e..bdfa67945788558192ead2efcaadcfb47c689fc5 100644 (file)
@@ -233,7 +233,6 @@ nextwild(
 
     if (xp->xp_numfiles == -1)
     {
-       may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
        pre_incsearch_pos = xp->xp_pre_incsearch_pos;
 #ifdef FEAT_EVAL
        if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS)
@@ -244,7 +243,9 @@ nextwild(
        else
 #endif
        {
+           may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
            set_expand_context(xp);
+           may_expand_pattern = FALSE;
        }
        cmd_showtail = expand_showtail(xp);
     }
index 47adb2b08f8e7e9b862f783b79d3f4b944f36117..46ace6616187093a71fd2b8e10d588259574f2e3 100644 (file)
@@ -4478,7 +4478,7 @@ func Test_search_complete()
   call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
   call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
   call feedkeys("gg/FO\<tab>\<f9>", 'tx')
-  call assert_equal({},  g:compl_info)
+  call assert_equal({}, g:compl_info)
   call feedkeys("gg/\\cFo\<tab>\<f9>", 'tx')
   call assert_equal(['\cFoobar', '\cFooBAr', '\cFooBARR'], g:compl_info.matches)
 
@@ -4498,7 +4498,12 @@ func Test_search_complete()
   call feedkeys("gg/Fo\<tab>\<f9>", 'tx')
   call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
   call feedkeys("gg/FO\<tab>\<f9>", 'tx')
-  call assert_equal({},  g:compl_info)
+  call assert_equal({}, g:compl_info)
+
+  " Issue #17680 (getcompletion() does not support search completion)
+  let result = getcompletion('%s/', 'cmdline')
+  call assert_equal([], result)
+
   call feedkeys("gg/foob\<tab>\<f9>", 'tx')
   call assert_equal(['foobar', 'foobarr'], g:compl_info.matches)
   call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
@@ -4603,43 +4608,43 @@ func Test_range_complete()
 
   for trig in ["\<tab>", "\<c-z>"]
     call feedkeys($":%s/a{trig}\<f9>", 'xt')
-    call assert_equal(['ab', 'a', 'af'],  g:compl_info.matches)
+    call assert_equal(['ab', 'a', 'af'], g:compl_info.matches)
     call feedkeys($":vim9cmd :%s/a{trig}\<f9>", 'xt')
-    call assert_equal(['ab', 'a', 'af'],  g:compl_info.matches)
+    call assert_equal(['ab', 'a', 'af'], g:compl_info.matches)
   endfor
 
   call feedkeys(":%s/\<c-z>\<f9>", 'xt')
-  call assert_equal({},  g:compl_info)
+  call assert_equal({}, g:compl_info)
 
   for cmd in ['s', 'g']
-    call feedkeys(":1,2" . cmd . "/a\<c-z>\<f9>", 'xt')
-    call assert_equal(['ab', 'a'],  g:compl_info.matches)
+    call feedkeys($":1,2{cmd}/a\<c-z>\<f9>", 'xt')
+    call assert_equal(['ab', 'a'], g:compl_info.matches)
   endfor
 
   1
   call feedkeys(":.,+2s/a\<c-z>\<f9>", 'xt')
-  call assert_equal(['ab', 'a'],  g:compl_info.matches)
+  call assert_equal(['ab', 'a'], g:compl_info.matches)
 
   /f
   call feedkeys(":1,s/b\<c-z>\<f9>", 'xt')
-  call assert_equal(['b', 'ba'],  g:compl_info.matches)
+  call assert_equal(['b', 'ba'], g:compl_info.matches)
 
   /c
   call feedkeys(":\\?,4s/a\<c-z>\<f9>", 'xt')
-  call assert_equal(['a', 'af'],  g:compl_info.matches)
+  call assert_equal(['a', 'af'], g:compl_info.matches)
 
   %s/c/c/
   call feedkeys(":1,\\&s/a\<c-z>\<f9>", 'xt')
-  call assert_equal(['ab', 'a'],  g:compl_info.matches)
+  call assert_equal(['ab', 'a'], g:compl_info.matches)
 
   3
   normal! ma
   call feedkeys(":'a,$s/a\<c-z>\<f9>", 'xt')
-  call assert_equal(['a', 'af'],  g:compl_info.matches)
+  call assert_equal(['a', 'af'], g:compl_info.matches)
 
   " Line number followed by a search pattern ([start]/pattern/[command])
   call feedkeys("3/a\<c-z>\<f9>", 'xt')
-  call assert_equal(['a', 'af', 'ab'],  g:compl_info.matches)
+  call assert_equal(['a', 'af', 'ab'], g:compl_info.matches)
 
   bw!
   call test_override("char_avail", 0)
index c84096053ca3a35a651be2a035915f35e3cb645b..e8979f9cba67f66ed7270b2a8a28b1c84060a4a5 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1528,
 /**/
     1527,
 /**/