]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash' v8.2.1747
authorBram Moolenaar <Bram@vim.org>
Sat, 26 Sep 2020 16:47:11 +0000 (18:47 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 26 Sep 2020 16:47:11 +0000 (18:47 +0200)
Problem:    Result of expand() unexpectedly depends on 'completeslash'.
Solution:   Temporarily reset 'completeslash'. (Yasuhiro Matsumoto,
            closes #7021)

src/evalfunc.c
src/testdir/test_ins_complete.vim
src/version.c

index 57c4ffbce8ff1e393fc3cd0f388dac11487c509a..afc8977532e48a3034e36d5be01995c5f7d08585 100644 (file)
@@ -2436,6 +2436,12 @@ f_expand(typval_T *argvars, typval_T *rettv)
     expand_T   xpc;
     int                error = FALSE;
     char_u     *result;
+#ifdef BACKSLASH_IN_FILENAME
+    char_u     *p_csl_save = p_csl;
+
+    // avoid using 'completeslash' here
+    p_csl = empty_option;
+#endif
 
     rettv->v_type = VAR_STRING;
     if (argvars[1].v_type != VAR_UNKNOWN
@@ -2488,6 +2494,9 @@ f_expand(typval_T *argvars, typval_T *rettv)
        else
            rettv->vval.v_string = NULL;
     }
+#ifdef BACKSLASH_IN_FILENAME
+    p_csl = p_csl_save;
+#endif
 }
 
 /*
index 992fefab43cd550fa818aa08fddd3f2013259adb..f77512ae186a9224a23ebdf99b4fd233a82f7fb0 100644 (file)
@@ -363,12 +363,12 @@ endfunc
 " Test for insert path completion with completeslash option
 func Test_ins_completeslash()
   CheckMSWindows
-  
+
   call mkdir('Xdir')
   let orig_shellslash = &shellslash
   set cpt&
   new
-  
+
   set noshellslash
 
   set completeslash=
@@ -654,4 +654,17 @@ func Test_complete_cmdline()
   close!
 endfunc
 
+func Test_issue_7021()
+  CheckMSWindows
+
+  let orig_shellslash = &shellslash
+  set noshellslash
+
+  set completeslash=slash
+  call assert_false(expand('~') =~ '/')
+
+  let &shellslash = orig_shellslash
+  set completeslash=
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 49ce61cab7a8df52c347e25674f34fc349d4d9fc..03765bf1b349085c50a5e7851f7b69167af47a38 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1747,
 /**/
     1746,
 /**/