]> granicus.if.org Git - vim/commitdiff
patch 8.1.1791: 'completeslash' also applies to globpath() v8.1.1791
authorBram Moolenaar <Bram@vim.org>
Fri, 2 Aug 2019 17:52:15 +0000 (19:52 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 2 Aug 2019 17:52:15 +0000 (19:52 +0200)
Problem:    'completeslash' also applies to globpath().
Solution:   Add the WILD_IGNORE_COMPLETESLASH flag. (test by Yasuhiro
            Matsumoto, closes #4760)

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

index 7eff7ad3572d779f4592f0229954111470eeaaa0..54fc2f5489f8a251d23a393c05924cf3c2a2ffef 100644 (file)
@@ -5878,15 +5878,15 @@ f_glob(typval_T *argvars, typval_T *rettv)
     static void
 f_globpath(typval_T *argvars, typval_T *rettv)
 {
-    int                flags = 0;
+    int                flags = WILD_IGNORE_COMPLETESLASH;
     char_u     buf1[NUMBUFLEN];
     char_u     *file = tv_get_string_buf_chk(&argvars[1], buf1);
     int                error = FALSE;
     garray_T   ga;
     int                i;
 
-    /* When the optional second argument is non-zero, don't remove matches
-    * for 'wildignore' and don't put matches for 'suffixes' at the end. */
+    // When the optional second argument is non-zero, don't remove matches
+    // for 'wildignore' and don't put matches for 'suffixes' at the end.
     rettv->v_type = VAR_STRING;
     if (argvars[2].v_type != VAR_UNKNOWN)
     {
index 7ef304ddbd7dc77b54975c2a7dd3bb607268f159..0e5d2baa667397e1c557ce5b4ebca27e857f1ab0 100644 (file)
@@ -5032,7 +5032,7 @@ ExpandFromContext(
     char_u     *pat,
     int                *num_file,
     char_u     ***file,
-    int                options)  /* EW_ flags */
+    int                options)  // WILD_ flags
 {
 #ifdef FEAT_CMDL_COMPL
     regmatch_T regmatch;
@@ -5096,7 +5096,7 @@ ExpandFromContext(
        if (free_pat)
            vim_free(pat);
 #ifdef BACKSLASH_IN_FILENAME
-       if (p_csl[0] != NUL)
+       if (p_csl[0] != NUL && (options & WILD_IGNORE_COMPLETESLASH) == 0)
        {
            int     i;
 
index fedb38acb5e3a8c627e830c469603ad6771f3683..e48a72c5d2caafd27be42fc09f104be89aea61ca 100644 (file)
@@ -1,3 +1,4 @@
+source check.vim
 
 " Test for insert expansion
 func Test_ins_complete()
@@ -334,15 +335,11 @@ endfunc
 
 " Test for insert path completion with completeslash option
 func Test_ins_completeslash()
-  if !has('win32')
-    throw 'Skipped: only works on MS-Windows'
-  endif
+  CheckMSWindows
   
   call mkdir('Xdir')
-
   let orig_shellslash = &shellslash
   set cpt&
-
   new
   
   set noshellslash
@@ -375,6 +372,11 @@ func Test_ins_completeslash()
   %bw!
   call delete('Xdir', 'rf')
 
+  set noshellslash
+  set completeslash=slash
+  call assert_true(stridx(globpath(&rtp, 'syntax/*.vim', 1, 1)[0], '\') != -1)
+
   let &shellslash = orig_shellslash
+  set completeslash=
 endfunc
 
index 81f59f9441997a311b34a9736fdb2ea3001e3248..e93ef430bef3fd5b817a6736e23d26d012abf1f7 100644 (file)
@@ -773,6 +773,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1791,
 /**/
     1790,
 /**/
index 99ffc10b705a605ab4dca4f70438065eeb00189d..6f7a11d63017c9c7ae1d3a14f095e4dd4ba4f81f 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -785,16 +785,17 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
 #define WILD_LONGEST           7
 #define WILD_ALL_KEEP          8
 
-#define WILD_LIST_NOTFOUND     0x01
-#define WILD_HOME_REPLACE      0x02
-#define WILD_USE_NL            0x04
-#define WILD_NO_BEEP           0x08
-#define WILD_ADD_SLASH         0x10
-#define WILD_KEEP_ALL          0x20
-#define WILD_SILENT            0x40
-#define WILD_ESCAPE            0x80
-#define WILD_ICASE             0x100
-#define WILD_ALLLINKS          0x200
+#define WILD_LIST_NOTFOUND         0x01
+#define WILD_HOME_REPLACE          0x02
+#define WILD_USE_NL                0x04
+#define WILD_NO_BEEP               0x08
+#define WILD_ADD_SLASH             0x10
+#define WILD_KEEP_ALL              0x20
+#define WILD_SILENT                0x40
+#define WILD_ESCAPE                0x80
+#define WILD_ICASE                 0x100
+#define WILD_ALLLINKS              0x200
+#define WILD_IGNORE_COMPLETESLASH   0x400
 
 // Flags for expand_wildcards()
 #define EW_DIR         0x01    // include directory names