patch 9.1.1226: "shellcmdline" completion doesn't work with input()

Commit: 
https://github.com/vim/vim/commit/7a5115ce50c622caf91503f9d7fe09c3749b928b
Author: zeertzjq <zeert...@outlook.com>
Date:   Wed Mar 19 20:29:58 2025 +0100

    patch 9.1.1226: "shellcmdline" completion doesn't work with input()
    
    Problem:  "shellcmdline" completion doesn't work with input().
    Solution: Use set_context_for_wildcard_arg().  Fix indent in nextwild()
              (zeertzjq).
    
    There are some other inconsistencies for input() completion (ref #948),
    but since "shellcmdline" currently doesn't work at all, it makse sense
    to at least make it work.
    
    fixes: #16932
    closes: #16934
    
    Signed-off-by: zeertzjq <zeert...@outlook.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/cmdexpand.c b/src/cmdexpand.c
index d21827733..85422b802 100644
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -15,6 +15,7 @@
 
 static int     cmd_showtail;   // Only show path tail in lists ?
 
+static void    set_context_for_wildcard_arg(exarg_T *eap, char_u *arg, int 
usefilter, expand_T *xp, int *complp);
 static int     ExpandFromContext(expand_T *xp, char_u *, char_u ***, int *, 
int);
 static char_u  *showmatches_gettail(char_u *s);
 static int     expand_showtail(expand_T *xp);
@@ -230,17 +231,17 @@ nextwild(
     if (xp->xp_numfiles == -1)
     {
 #ifdef FEAT_EVAL
-        if (ccline->input_fn && ccline->xp_context == EXPAND_COMMANDS)
+       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
+       }
+       else
 #endif
-        {
+       {
            set_expand_context(xp);
-        }
-        cmd_showtail = expand_showtail(xp);
+       }
+       cmd_showtail = expand_showtail(xp);
     }
 
     if (xp->xp_context == EXPAND_UNSUCCESSFUL)
@@ -2723,6 +2724,7 @@ set_cmd_context(
 {
 #ifdef FEAT_EVAL
     cmdline_info_T     *ccline = get_cmdline_info();
+    int                        context;
 #endif
     int                old_char = NUL;
     char_u     *nextcomm;
@@ -2745,6 +2747,12 @@ set_cmd_context(
        xp->xp_context = ccline->xp_context;
        xp->xp_pattern = ccline->cmdbuff;
        xp->xp_arg = ccline->xp_arg;
+       if (xp->xp_context == EXPAND_SHELLCMDLINE)
+       {
+           context = xp->xp_context;
+           set_context_for_wildcard_arg(NULL, xp->xp_pattern, FALSE, xp,
+                                                                    &context);
+       }
     }
     else
 #endif
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index c498ec0a3..28800f1e3 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -2245,10 +2245,20 @@ 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
+  " 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)
+
+  " Test for using "shellcmdline" as the completion function
+  call feedkeys(":let c = input('Shell? ', '', 'shellcmdline')\<CR>"
+        \ .. "vim test_functions.\<C-A>\<CR>", 'xt')
+  call assert_equal('vim test_functions.vim', c)
+  if executable('whoami')
+    call feedkeys(":let c = input('Shell? ', '', 'shellcmdline')\<CR>"
+          \ .. "whoam\<C-A>\<CR>", 'xt')
+    call assert_match('\<whoami\>', c)
+  endif
 endfunc
 
 " Test for the inputdialog() function
diff --git a/src/version.c b/src/version.c
index aab2ea560..c6b6fe0ef 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 */
+/**/
+    1226,
 /**/
     1225,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tuzLb-003Aeo-VF%40256bit.org.

Raspunde prin e-mail lui