Skip to content

Commit 3255af8

Browse files
JimZhouZZYchrisbra
authored andcommitted
patch 9.1.1157: command completion wrong for input()
Problem: command completion wrong for input() (Cdrman Fu) Solution: Set commandline completion context explicitly (Jim Zhou) fixes #16723 closes: #16733 Signed-off-by: Jim Zhou <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 85a50fe commit 3255af8

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/cmdexpand.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,18 @@ nextwild(
229229

230230
if (xp->xp_numfiles == -1)
231231
{
232-
set_expand_context(xp);
233-
cmd_showtail = expand_showtail(xp);
232+
#ifdef FEAT_EVAL
233+
if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS)
234+
{
235+
// Expand commands typed in input() function
236+
set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, FALSE);
237+
}
238+
else
239+
#endif
240+
{
241+
set_expand_context(xp);
242+
}
243+
cmd_showtail = expand_showtail(xp);
234244
}
235245

236246
if (xp->xp_context == EXPAND_UNSUCCESSFUL)

src/testdir/test_functions.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,11 @@ func Test_input_func()
22442244

22452245
call assert_fails("call input('F:', '', 'invalid')", 'E180:')
22462246
call assert_fails("call input('F:', '', [])", 'E730:')
2247+
2248+
" Test for using 'command' as the completion function
2249+
call feedkeys(":let c = input('Command? ', '', 'command')\<CR>"
2250+
\ .. "echo bufnam\<C-A>\<CR>", 'xt')
2251+
call assert_equal('echo bufname(', c)
22472252
endfunc
22482253

22492254
" Test for the inputdialog() function

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1157,
707709
/**/
708710
1156,
709711
/**/

0 commit comments

Comments
 (0)