patch 9.1.1639: completion: popup may be misplaced

Problem:  During commandline completiom, popup window placement can be
          incorrect when 'noselect' is present in 'wildmode'
          (Shane-XB-Qian)
Solution: Disable "showtail" feature when 'noselect' is present.

fixes: #17969
closes: #18001

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya
2025-08-16 18:13:46 +02:00
committed by Christian Brabandt
parent a09b1604d4
commit 1e38198a41
7 changed files with 82 additions and 29 deletions

View File

@ -946,10 +946,11 @@ cmdline_wildchar_complete(
int res;
int j;
int options = WILD_NO_BEEP;
int noselect = (wim_flags[0] & WIM_NOSELECT) != 0;
if (wim_flags[wim_index] & WIM_BUFLASTUSED)
options |= WILD_BUFLASTUSED;
if (wim_flags[0] & WIM_NOSELECT)
if (noselect)
options |= WILD_KEEP_SOLE_ITEM;
if (xp->xp_numfiles > 0) // typed p_wc at least twice
{
@ -960,7 +961,8 @@ cmdline_wildchar_complete(
|| (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)))
{
(void)showmatches(xp,
p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0));
p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0),
noselect);
redrawcmd();
*did_wild_list = TRUE;
}
@ -1011,7 +1013,7 @@ cmdline_wildchar_complete(
// "list", or no change and 'wildmode' contains "longest,list",
// list all matches
if (res == OK
&& xp->xp_numfiles > ((wim_flags[wim_index] & WIM_NOSELECT) ? 0 : 1))
&& xp->xp_numfiles > (noselect ? 0 : 1))
{
// a "longest" that didn't do anything is skipped (but not
// "list:longest")
@ -1031,7 +1033,7 @@ cmdline_wildchar_complete(
p_wmnu = p_wmnu_save;
}
(void)showmatches(xp, p_wmnu
&& ((wim_flags[wim_index] & WIM_LIST) == 0));
&& ((wim_flags[wim_index] & WIM_LIST) == 0), noselect);
redrawcmd();
*did_wild_list = TRUE;
if (wim_flags[wim_index] & WIM_LONGEST)
@ -2013,7 +2015,8 @@ getcmdline_int(
{
if (cmdline_pum_active())
{
skip_pum_redraw = skip_pum_redraw && (vim_isprintc(c)
skip_pum_redraw = skip_pum_redraw && !key_is_wc
&& (vim_isprintc(c)
|| c == K_BS || c == Ctrl_H || c == K_DEL
|| c == K_KDEL || c == Ctrl_W || c == Ctrl_U);
cmdline_pum_remove(&ccline, skip_pum_redraw);
@ -2124,7 +2127,8 @@ getcmdline_int(
{
// Trigger the popup menu when wildoptions=pum
showmatches(&xpc, p_wmnu
&& ((wim_flags[wim_index] & WIM_LIST) == 0));
&& ((wim_flags[wim_index] & WIM_LIST) == 0),
wim_flags[0] & WIM_NOSELECT);
}
if (nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK
&& nextwild(&xpc, WILD_PREV, 0, firstc != '@') == OK)
@ -2239,7 +2243,8 @@ getcmdline_int(
goto cmdline_not_changed;
case Ctrl_D:
if (showmatches(&xpc, FALSE) == EXPAND_NOTHING)
if (showmatches(&xpc, FALSE, wim_flags[0] & WIM_NOSELECT)
== EXPAND_NOTHING)
break; // Use ^D as normal char instead
redrawcmd();