]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1157: command completion wrong for input() v9.1.1157
authorJim Zhou <csd_189@163.com>
Thu, 27 Feb 2025 18:29:50 +0000 (19:29 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 27 Feb 2025 18:29:50 +0000 (19:29 +0100)
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 <csd_189@163.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/cmdexpand.c
src/testdir/test_functions.vim
src/version.c

index c14eee2c93581cd7b5ce21e487744eb405d6af52..9f24429f46b13049a96dd7a6a51f5eccd933a9bc 100644 (file)
@@ -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)
index 6928cda8d4ba5d0a1e88912a61760bdae933ed7b..724fda05c363f3d2268946c628c1127194842dcc 100644 (file)
@@ -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
index ef3ca2e38ed97d5d41eff57be1bb3b22bdddf4a8..94db286ee63d3d85a078104ba403c13826c7e0a3 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1157,
 /**/
     1156,
 /**/