]> granicus.if.org Git - vim/commitdiff
patch 8.2.2206: :exe command line completion only works for first argument v8.2.2206
authorBram Moolenaar <Bram@vim.org>
Thu, 24 Dec 2020 16:15:53 +0000 (17:15 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 24 Dec 2020 16:15:53 +0000 (17:15 +0100)
Problem:    :exe command line completion only works for first argument.
Solution:   Skip over text if more is following. (closes #7546)

src/eval.c
src/testdir/test_cmdline.vim
src/version.c

index e4149ab9d2c3c29dd0e7b50d3f8f89c88291f584..e61207048ccf9782d00cad2ebc7ac00b64e4a34e 100644 (file)
@@ -1904,6 +1904,24 @@ set_context_for_expression(
            while ((c = *++arg) != NUL && (c == ' ' || c == '\t'))
                /* skip */ ;
     }
+
+    // ":exe one two" completes "two"
+    if ((cmdidx == CMD_execute
+               || cmdidx == CMD_echo
+               || cmdidx == CMD_echon
+               || cmdidx == CMD_echomsg)
+           && xp->xp_context == EXPAND_EXPRESSION)
+    {
+       for (;;)
+       {
+           char_u *n = skiptowhite(arg);
+
+           if (n == arg || IS_WHITE_OR_NUL(*skipwhite(n)))
+               break;
+           arg = skipwhite(n);
+       }
+    }
+
     xp->xp_pattern = arg;
 }
 
index 600a571a179d41229a0f6c9a842b9e3c15d13f1e..1c5cac76bf1f5ae7f0e7cb7350fab666db138c1e 100644 (file)
@@ -673,6 +673,17 @@ func Test_cmdline_complete_env_variable()
   unlet $X_VIM_TEST_COMPLETE_ENV
 endfunc
 
+func Test_cmdline_complete_expression()
+  let g:SomeVar = 'blah'
+  for cmd in ['exe', 'echo', 'echon', 'echomsg']
+    call feedkeys(":" .. cmd .. " SomeV\<Tab>\<C-B>\"\<CR>", 'tx')
+    call assert_match('"' .. cmd .. ' SomeVar', @:)
+    call feedkeys(":" .. cmd .. " foo SomeV\<Tab>\<C-B>\"\<CR>", 'tx')
+    call assert_match('"' .. cmd .. ' foo SomeVar', @:)
+  endfor
+  unlet g:SomeVar
+endfunc
+
 " Test for various command-line completion
 func Test_cmdline_complete_various()
   " completion for a command starting with a comment
index 5420862e2c6dc0a6cb9738b730e8f39b32ae5998..adba2cd4e2a68375fb6e59f35e4f0fca475e8ea6 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2206,
 /**/
     2205,
 /**/