mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 17:28:23 +00:00
vim-patch:8.2.4475: fuzzy cmdline completion does not work for lower case
Problem: Fuzzy cmdline completion does not work for lower case.
Solution: Also use fuzzy completion for lower case input. (Yegappan
Lakshmanan, closes vim/vim#9849)
4df5b33f20
Initialize "regmatch" to avoid using uninitialized memory.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -1373,6 +1373,7 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in
|
|||||||
{
|
{
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
const bool fuzzy = cmdline_fuzzy_complete(cmd);
|
||||||
|
|
||||||
// Isolate the command and search for it in the command table.
|
// Isolate the command and search for it in the command table.
|
||||||
// Exceptions:
|
// Exceptions:
|
||||||
@@ -1413,7 +1414,9 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in
|
|||||||
|
|
||||||
eap->cmdidx = excmd_get_cmdidx(cmd, len);
|
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
|
while (ASCII_ISALNUM(*p) || *p == '*') { // Allow * wild card
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@@ -2630,9 +2633,10 @@ static int map_wildopts_to_ewflags(int options)
|
|||||||
/// @param options WILD_ flags
|
/// @param options WILD_ flags
|
||||||
static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numMatches, int options)
|
static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numMatches, int options)
|
||||||
{
|
{
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch = { .rm_ic = false };
|
||||||
int ret;
|
int ret;
|
||||||
int flags = map_wildopts_to_ewflags(options);
|
int flags = map_wildopts_to_ewflags(options);
|
||||||
|
const bool fuzzy = cmdline_fuzzy_complete(pat);
|
||||||
|
|
||||||
if (xp->xp_context == EXPAND_FILES
|
if (xp->xp_context == EXPAND_FILES
|
||||||
|| xp->xp_context == EXPAND_DIRECTORIES
|
|| xp->xp_context == EXPAND_DIRECTORIES
|
||||||
@@ -2713,13 +2717,15 @@ static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numM
|
|||||||
return nlua_expand_pat(xp, pat, numMatches, matches);
|
return nlua_expand_pat(xp, pat, numMatches, matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
|
if (!fuzzy) {
|
||||||
if (regmatch.regprog == NULL) {
|
regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0);
|
||||||
return FAIL;
|
if (regmatch.regprog == NULL) {
|
||||||
}
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
// set ignore-case according to p_ic, p_scs and pat
|
// set ignore-case according to p_ic, p_scs and pat
|
||||||
regmatch.rm_ic = ignorecase(pat);
|
regmatch.rm_ic = ignorecase(pat);
|
||||||
|
}
|
||||||
|
|
||||||
if (xp->xp_context == EXPAND_SETTINGS
|
if (xp->xp_context == EXPAND_SETTINGS
|
||||||
|| xp->xp_context == EXPAND_BOOL_SETTINGS) {
|
|| xp->xp_context == EXPAND_BOOL_SETTINGS) {
|
||||||
@@ -2732,7 +2738,9 @@ static int ExpandFromContext(expand_T *xp, char *pat, char ***matches, int *numM
|
|||||||
ret = ExpandOther(pat, xp, ®match, matches, numMatches);
|
ret = ExpandOther(pat, xp, ®match, matches, numMatches);
|
||||||
}
|
}
|
||||||
|
|
||||||
vim_regfree(regmatch.regprog);
|
if (!fuzzy) {
|
||||||
|
vim_regfree(regmatch.regprog);
|
||||||
|
}
|
||||||
xfree(tofree);
|
xfree(tofree);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -2989,6 +2989,18 @@ func Test_wildoptions_fuzzy()
|
|||||||
delcommand T123FendingOff
|
delcommand T123FendingOff
|
||||||
%bw
|
%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&
|
set wildoptions&
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user