patch 8.2.4608: getcompletion() does not work when 'wildoptions' has "fuzzy"
Problem: getcompletion() does not work properly when 'wildoptions
contains "fuzzy".
Solution: Do not use addstar(). (Yegappan Lakshmanan, closes #9992,
closes #9986)
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index 5ba6b08..defc282 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -3707,7 +3707,12 @@
# endif
}
- pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
+ if (cmdline_fuzzy_completion_supported(&xpc))
+ // when fuzzy matching, don't modify the search string
+ pat = vim_strsave(xpc.xp_pattern);
+ else
+ pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
+
if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL))
{
int i;
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index dc781f8..299210b 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -552,6 +552,22 @@
call assert_fails('call getcompletion("abc", [])', 'E475:')
endfunc
+" Test for getcompletion() with "fuzzy" in 'wildoptions'
+func Test_getcompletion_wildoptions()
+ let save_wildoptions = &wildoptions
+ set wildoptions&
+ let l = getcompletion('space', 'option')
+ call assert_equal([], l)
+ let l = getcompletion('ier', 'command')
+ call assert_equal([], l)
+ set wildoptions=fuzzy
+ let l = getcompletion('space', 'option')
+ call assert_true(index(l, 'backspace') >= 0)
+ let l = getcompletion('ier', 'command')
+ call assert_true(index(l, 'compiler') >= 0)
+ let &wildoptions = save_wildoptions
+endfunc
+
func Test_complete_autoload_error()
let save_rtp = &rtp
let lines =<< trim END
diff --git a/src/version.c b/src/version.c
index 2c2ac28..2180ebf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4608,
+/**/
4607,
/**/
4606,