vim-patch:9.1.1157: command completion wrong for input() (#32669)

Problem:  command completion wrong for input()
          (Cdrman Fu)
Solution: Set commandline completion context explicitly
          (Jim Zhou)

fixes vim/vim#16723
closes: vim/vim#16733

3255af850e

Co-authored-by: Jim Zhou <csd_189@163.com>
This commit is contained in:
zeertzjq
2025-02-28 08:23:02 +08:00
committed by GitHub
parent 3eee6f9d63
commit 332d596959
2 changed files with 11 additions and 1 deletions

View File

@@ -242,7 +242,12 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
char *p2; char *p2;
if (xp->xp_numfiles == -1) { if (xp->xp_numfiles == -1) {
set_expand_context(xp); if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS) {
// Expand commands typed in input() function
set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, false);
} else {
set_expand_context(xp);
}
if (xp->xp_context == EXPAND_LUA) { if (xp->xp_context == EXPAND_LUA) {
nlua_expand_pat(xp); nlua_expand_pat(xp);
} }

View File

@@ -2071,6 +2071,11 @@ func Test_input_func()
call assert_fails("call input('F:', '', 'invalid')", 'E180:') call assert_fails("call input('F:', '', 'invalid')", 'E180:')
call assert_fails("call input('F:', '', [])", 'E730:') call assert_fails("call input('F:', '', [])", 'E730:')
" Test for using 'command' as the completion function
call feedkeys(":let c = input('Command? ', '', 'command')\<CR>"
\ .. "echo bufnam\<C-A>\<CR>", 'xt')
call assert_equal('echo bufname(', c)
endfunc endfunc
" Test for the inputdialog() function " Test for the inputdialog() function