changeset 23322:68df9697667a v8.2.2206

patch 8.2.2206: :exe command line completion only works for first argument Commit: https://github.com/vim/vim/commit/4941b5effd7f6a26583a949c92ee50276a3b43f9 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 24 17:15:53 2020 +0100 patch 8.2.2206: :exe command line completion only works for first argument Problem: :exe command line completion only works for first argument. Solution: Skip over text if more is following. (closes https://github.com/vim/vim/issues/7546)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Dec 2020 17:30:04 +0100
parents 86d163526c2d
children 40bdf1ead7d7
files src/eval.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -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;
 }
 
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2206,
+/**/
     2205,
 /**/
     2204,