diff options
-rw-r--r-- | src/nvim/cmdexpand.c | 7 | ||||
-rw-r--r-- | test/old/testdir/test_functions.vim | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 5421e9dd5c..33ccc834d2 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -242,7 +242,12 @@ int nextwild(expand_T *xp, int type, int options, bool escape) char *p2; 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) { nlua_expand_pat(xp); } diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index 6b216947a7..7c6c32f3c4 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -2071,6 +2071,11 @@ func Test_input_func() call assert_fails("call input('F:', '', 'invalid')", 'E180:') 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 " Test for the inputdialog() function |