]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4478: crash when using fuzzy completion v8.2.4478
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 26 Feb 2022 16:05:08 +0000 (16:05 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Feb 2022 16:05:08 +0000 (16:05 +0000)
Problem:    Crash when using fuzzy completion.
Solution:   Temporary fix: put back regexp. (closes #9852, closes #9851)

src/cmdexpand.c
src/testdir/test_cmdline.vim
src/version.c

index dd8bc06d09b35b51961c210b72390d6ab03ddd00..003f6daf1e70dd3b1c410940fa08dd78bb748ce2 100644 (file)
@@ -2496,6 +2496,8 @@ ExpandFromContext(
     int                ret;
     int                flags;
     char_u     *tofree = NULL;
+    int                fuzzy = cmdline_fuzzy_complete(pat)
+                                    && cmdline_fuzzy_completion_supported(xp);
 
     flags = map_wildopts_to_ewflags(options);
 
@@ -2580,12 +2582,15 @@ ExpandFromContext(
        pat = tofree;
     }
 
-    regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
-    if (regmatch.regprog == NULL)
-       return FAIL;
+    if (!fuzzy)
+    {
+       regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
+       if (regmatch.regprog == NULL)
+           return FAIL;
 
-    // set ignore-case according to p_ic, p_scs and pat
-    regmatch.rm_ic = ignorecase(pat);
+       // set ignore-case according to p_ic, p_scs and pat
+       regmatch.rm_ic = ignorecase(pat);
+    }
 
     if (xp->xp_context == EXPAND_SETTINGS
            || xp->xp_context == EXPAND_BOOL_SETTINGS)
@@ -2599,7 +2604,8 @@ ExpandFromContext(
     else
        ret = ExpandOther(pat, xp, &regmatch, matches, numMatches);
 
-    vim_regfree(regmatch.regprog);
+    if (!fuzzy)
+       vim_regfree(regmatch.regprog);
     vim_free(tofree);
 
     return ret;
index c83a8f14700205065d350b51abf75558f71bd9b0..2fc19c6fb42d4e62368022d2968e1934ed62262a 100644 (file)
@@ -2659,6 +2659,10 @@ func Test_wildoptions_fuzzy()
   call assert_equal('"mapclear <buffer>', @:)
 
   " map name fuzzy completion - NOT supported
+  " test regex completion works
+  set wildoptions=fuzzy
+  call feedkeys(":cnoremap <ex\<Tab> <esc> \<Tab>\<C-B>\"\<CR>", 'tx')
+  call assert_equal("\"cnoremap <expr> <esc> \<Tab>", @:)
 
   " menu name fuzzy completion
   if has('gui_running')
index c8511d2b48397d6062f0f281a6051814c9f92f20..c77f76134cc828d42b0d6862e254d6660ab490d0 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4478,
 /**/
     4477,
 /**/