patch 9.1.1576: cannot easily trigger wildcard expansion
Problem: cannot easily trigger wildcard expansion
Solution: Introduce wildtrigger() function
(Girish Palya)
This PR introduces a new `wildtrigger()` function.
See `:h wildtrigger()`
`wildtrigger()` behaves like pressing the `wildchar,` but provides a
more refined and controlled completion experience:
- Suppresses beeps when no matches are found.
- Avoids displaying irrelevant completions (like full command lists)
when the prefix is insufficient or doesn't match.
- Skips completion if the typeahead buffer has pending input or if a
wildmenu is already active.
- Does not print "..." before completion.
This is an improvement on the `feedkeys()` based autocompletion script
given in #16759.
closes: #17806
Signed-off-by: Girish Palya <girishji@gmail.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
689f3bf313
commit
b486ed8266
@ -238,6 +238,7 @@ nextwild(
|
||||
cmdline_info_T *ccline = get_cmdline_info();
|
||||
int i;
|
||||
char_u *p;
|
||||
int from_wildtrigger_func = options & WILD_FUNC_TRIGGER;
|
||||
|
||||
if (xp->xp_numfiles == -1)
|
||||
{
|
||||
@ -269,17 +270,22 @@ nextwild(
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||
xp->xp_pattern_len = ccline->cmdpos - i;
|
||||
|
||||
// Skip showing matches if prefix is invalid during wildtrigger()
|
||||
if (from_wildtrigger_func && xp->xp_context == EXPAND_COMMANDS
|
||||
&& xp->xp_pattern_len == 0)
|
||||
return FAIL;
|
||||
|
||||
// If cmd_silent is set then don't show the dots, because redrawcmd() below
|
||||
// won't remove them.
|
||||
if (!cmd_silent)
|
||||
if (!cmd_silent && !from_wildtrigger_func)
|
||||
{
|
||||
msg_puts("..."); // show that we are busy
|
||||
out_flush();
|
||||
}
|
||||
|
||||
i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||
xp->xp_pattern_len = ccline->cmdpos - i;
|
||||
|
||||
if (type == WILD_NEXT || type == WILD_PREV
|
||||
|| type == WILD_PAGEUP || type == WILD_PAGEDOWN)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user