fix(cmdline): do not trigger completion at wrong time (#19920)

Cherry-picked from Vim patches 8.2.4339, 9.0.0238.
This commit is contained in:
zeertzjq
2022-08-24 10:28:32 +08:00
committed by GitHub
parent 64d147b471
commit 9a100ee169
3 changed files with 82 additions and 10 deletions

View File

@@ -1277,8 +1277,11 @@ static int command_line_execute(VimState *state, int key)
// <S-Tab> goes to last match, in a clumsy way
if (s->c == K_S_TAB && KeyTyped) {
if (nextwild(&s->xpc, WILD_EXPAND_KEEP, 0, s->firstc != '@') == OK) {
// Trigger the popup menu when wildoptions=pum
showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
if (s->xpc.xp_numfiles > 1
&& ((!s->did_wild_list && (wim_flags[s->wim_index] & WIM_LIST)) || p_wmnu)) {
// Trigger the popup menu when wildoptions=pum
showmatches(&s->xpc, p_wmnu && ((wim_flags[s->wim_index] & WIM_LIST) == 0));
}
nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@');
nextwild(&s->xpc, WILD_PREV, 0, s->firstc != '@');
return command_line_changed(s);
@@ -1798,13 +1801,16 @@ static int command_line_handle_key(CommandLineState *s)
return command_line_not_changed(s);
case Ctrl_A: // all matches
if (cmdline_pum_active()) {
// As Ctrl-A completes all the matches, close the popup
// menu (if present)
cmdline_pum_cleanup(&ccline);
}
if (nextwild(&s->xpc, WILD_ALL, 0, s->firstc != '@') == FAIL) {
break;
}
if (cmdline_pum_active()) {
cmdline_pum_cleanup(&ccline);
s->xpc.xp_context = EXPAND_NOTHING;
}
s->xpc.xp_context = EXPAND_NOTHING;
s->did_wild_list = false;
return command_line_changed(s);
case Ctrl_L: