patch 9.1.1157: command completion wrong for input()
Commit:
https://github.com/vim/vim/commit/3255af850e8bab35c30fce4177bb5ba4a941e6ce
Author: Jim Zhou <[email protected]>
Date: Thu Feb 27 19:29:50 2025 +0100
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]>
diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index c14eee2c9..9f24429f4 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -229,8 +229,18 @@ nextwild(
if (xp->xp_numfiles == -1)
{
- set_expand_context(xp);
- cmd_showtail = expand_showtail(xp);
+#ifdef FEAT_EVAL
+ 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
+#endif
+ {
+ set_expand_context(xp);
+ }
+ cmd_showtail = expand_showtail(xp);
}
if (xp->xp_context == EXPAND_UNSUCCESSFUL)
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 6928cda8d..724fda05c 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2244,6 +2244,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
diff --git a/src/version.c b/src/version.c
index ef3ca2e38..94db286ee 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1157,
/**/
1156,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1tnisZ-00GcvD-HJ%40256bit.org.