{
char_u *p = NULL;
int len = 0;
+ int fuzzy = cmdline_fuzzy_complete(cmd);
// Isolate the command and search for it in the command table.
// Exceptions:
eap->cmdidx = excmd_get_cmdidx(cmd, len);
- if (cmd[0] >= 'A' && cmd[0] <= 'Z')
+ // User defined commands support alphanumeric characters.
+ // Also when doing fuzzy expansion, support alphanumeric characters.
+ if ((cmd[0] >= 'A' && cmd[0] <= 'Z') || (fuzzy && *p != NUL))
while (ASCII_ISALNUM(*p) || *p == '*') // Allow * wild card
++p;
}
int ret;
int flags;
char_u *tofree = NULL;
+ int fuzzy = cmdline_fuzzy_complete(pat);
flags = map_wildopts_to_ewflags(options);
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)
else
ret = ExpandOther(pat, xp, ®match, matches, numMatches);
- vim_regfree(regmatch.regprog);
+ if (!fuzzy)
+ vim_regfree(regmatch.regprog);
vim_free(tofree);
return ret;
delcommand T123FendingOff
%bw
+ " Test for fuzzy completion of a command with lower case letters and a
+ " number
+ command Foo2Bar :
+ set wildoptions=fuzzy
+ call feedkeys(":foo2\<Tab>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"Foo2Bar', @:)
+ call feedkeys(":foo\<Tab>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"Foo2Bar', @:)
+ call feedkeys(":bar\<Tab>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"Foo2Bar', @:)
+ delcommand Foo2Bar
+
set wildoptions&
%bw!
endfunc