changeset 27906:11141b2ec0e1 v8.2.4478

patch 8.2.4478: crash when using fuzzy completion Commit: https://github.com/vim/vim/commit/00333cb3b341499df8729b9345f0bbad968cda0b Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Feb 26 16:05:08 2022 +0000 patch 8.2.4478: crash when using fuzzy completion Problem: Crash when using fuzzy completion. Solution: Temporary fix: put back regexp. (closes https://github.com/vim/vim/issues/9852, closes https://github.com/vim/vim/issues/9851)
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Feb 2022 17:15:03 +0100
parents 2a041179bd13
children 172f5b915674
files src/cmdexpand.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -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;
-
-    // set ignore-case according to p_ic, p_scs and pat
-    regmatch.rm_ic = ignorecase(pat);
+    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);
+    }
 
     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;
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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')
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4478,
+/**/
     4477,
 /**/
     4476,