changeset 25684:ba9d587f0b29 v8.2.3378

patch 8.2.3378: MS-Windows: completing environment variables with % is wrong Commit: https://github.com/vim/vim/commit/6024c0427ce1196344439997d5e41a6f8546368c Author: Albert Liu <albertymliu@gmail.com> Date: Fri Aug 27 20:59:35 2021 +0200 patch 8.2.3378: MS-Windows: completing environment variables with % is wrong Problem: MS-Windows: completing environment variables with % is wrong. Solution: Only complete environment variables with $. (Albert Liu, closes #8791)
author Bram Moolenaar <Bram@vim.org>
date Fri, 27 Aug 2021 21:00:04 +0200
parents 7be599085162
children 6d11c7a81208
files src/cmdexpand.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/cmdexpand.c
+++ b/src/cmdexpand.c
@@ -1277,12 +1277,8 @@ set_one_cmd_context(
 		xp->xp_context = EXPAND_SHELLCMD;
 	}
 
-	// Check for environment variable
-	if (*xp->xp_pattern == '$'
-#if defined(MSWIN)
-		|| *xp->xp_pattern == '%'
-#endif
-		)
+	// Check for environment variable.
+	if (*xp->xp_pattern == '$')
 	{
 	    for (p = xp->xp_pattern + 1; *p != NUL; ++p)
 		if (!vim_isIDc(*p))
@@ -1296,7 +1292,7 @@ set_one_cmd_context(
 		    compl = EXPAND_ENV_VARS;
 	    }
 	}
-	// Check for user names
+	// Check for user names.
 	if (*xp->xp_pattern == '~')
 	{
 	    for (p = xp->xp_pattern + 1; *p != NUL && *p != '/'; ++p)
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -9,6 +9,10 @@ func Test_complete_tab()
   call writefile(['testfile'], 'Xtestfile')
   call feedkeys(":e Xtest\t\r", "tx")
   call assert_equal('testfile', getline(1))
+
+  " Pressing <Tab> after '%' completes the current file, also on MS-Windows
+  call feedkeys(":e %\t\r", "tx")
+  call assert_equal('e Xtestfile', @:)
   call delete('Xtestfile')
 endfunc
 
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3378,
+/**/
     3377,
 /**/
     3376,