patch 9.1.1528: completion: crash with getcompletion()

Problem:  completion: crash with getcompletion()
          (zeertzjq)
Solution: Don't set may_expand_pattern in f_getcompletion(),
          unset may_expand_pattern() once it is not longer needed
          (Girish Palya).

fixes: #17680
closes: #17686

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2025-07-08 22:04:10 +02:00
parent 2ffd35fe8f
commit f2ec8d4afc
3 changed files with 22 additions and 14 deletions

View File

@ -233,7 +233,6 @@ nextwild(
if (xp->xp_numfiles == -1)
{
may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
pre_incsearch_pos = xp->xp_pre_incsearch_pos;
#ifdef FEAT_EVAL
if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS)
@ -244,7 +243,9 @@ nextwild(
else
#endif
{
may_expand_pattern = options & WILD_MAY_EXPAND_PATTERN;
set_expand_context(xp);
may_expand_pattern = FALSE;
}
cmd_showtail = expand_showtail(xp);
}

View File

@ -4499,6 +4499,11 @@ func Test_search_complete()
call assert_equal(['Foobar', 'FooBARR'], g:compl_info.matches)
call feedkeys("gg/FO\<tab>\<f9>", 'tx')
call assert_equal({}, g:compl_info)
" Issue #17680 (getcompletion() does not support search completion)
let result = getcompletion('%s/', 'cmdline')
call assert_equal([], result)
call feedkeys("gg/foob\<tab>\<f9>", 'tx')
call assert_equal(['foobar', 'foobarr'], g:compl_info.matches)
call feedkeys("gg/\\Cfo\<tab>\<f9>", 'tx')
@ -4612,7 +4617,7 @@ func Test_range_complete()
call assert_equal({}, g:compl_info)
for cmd in ['s', 'g']
call feedkeys(":1,2" . cmd . "/a\<c-z>\<f9>", 'xt')
call feedkeys($":1,2{cmd}/a\<c-z>\<f9>", 'xt')
call assert_equal(['ab', 'a'], g:compl_info.matches)
endfor

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1528,
/**/
1527,
/**/