0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.1791: 'completeslash' also applies to globpath()

Problem:    'completeslash' also applies to globpath().
Solution:   Add the WILD_IGNORE_COMPLETESLASH flag. (test by Yasuhiro
            Matsumoto, closes #4760)
This commit is contained in:
Bram Moolenaar
2019-08-02 19:52:15 +02:00
parent 8750026a7f
commit 50f91d22bd
5 changed files with 25 additions and 20 deletions

View File

@@ -5878,15 +5878,15 @@ f_glob(typval_T *argvars, typval_T *rettv)
static void static void
f_globpath(typval_T *argvars, typval_T *rettv) f_globpath(typval_T *argvars, typval_T *rettv)
{ {
int flags = 0; int flags = WILD_IGNORE_COMPLETESLASH;
char_u buf1[NUMBUFLEN]; char_u buf1[NUMBUFLEN];
char_u *file = tv_get_string_buf_chk(&argvars[1], buf1); char_u *file = tv_get_string_buf_chk(&argvars[1], buf1);
int error = FALSE; int error = FALSE;
garray_T ga; garray_T ga;
int i; int i;
/* When the optional second argument is non-zero, don't remove matches // When the optional second argument is non-zero, don't remove matches
* for 'wildignore' and don't put matches for 'suffixes' at the end. */ // for 'wildignore' and don't put matches for 'suffixes' at the end.
rettv->v_type = VAR_STRING; rettv->v_type = VAR_STRING;
if (argvars[2].v_type != VAR_UNKNOWN) if (argvars[2].v_type != VAR_UNKNOWN)
{ {

View File

@@ -5032,7 +5032,7 @@ ExpandFromContext(
char_u *pat, char_u *pat,
int *num_file, int *num_file,
char_u ***file, char_u ***file,
int options) /* EW_ flags */ int options) // WILD_ flags
{ {
#ifdef FEAT_CMDL_COMPL #ifdef FEAT_CMDL_COMPL
regmatch_T regmatch; regmatch_T regmatch;
@@ -5096,7 +5096,7 @@ ExpandFromContext(
if (free_pat) if (free_pat)
vim_free(pat); vim_free(pat);
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
if (p_csl[0] != NUL) if (p_csl[0] != NUL && (options & WILD_IGNORE_COMPLETESLASH) == 0)
{ {
int i; int i;

View File

@@ -1,3 +1,4 @@
source check.vim
" Test for insert expansion " Test for insert expansion
func Test_ins_complete() func Test_ins_complete()
@@ -334,15 +335,11 @@ endfunc
" Test for insert path completion with completeslash option " Test for insert path completion with completeslash option
func Test_ins_completeslash() func Test_ins_completeslash()
if !has('win32') CheckMSWindows
throw 'Skipped: only works on MS-Windows'
endif
call mkdir('Xdir') call mkdir('Xdir')
let orig_shellslash = &shellslash let orig_shellslash = &shellslash
set cpt& set cpt&
new new
set noshellslash set noshellslash
@@ -375,6 +372,11 @@ func Test_ins_completeslash()
%bw! %bw!
call delete('Xdir', 'rf') 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 let &shellslash = orig_shellslash
set completeslash=
endfunc endfunc

View File

@@ -773,6 +773,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1791,
/**/ /**/
1790, 1790,
/**/ /**/

View File

@@ -795,6 +795,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
#define WILD_ESCAPE 0x80 #define WILD_ESCAPE 0x80
#define WILD_ICASE 0x100 #define WILD_ICASE 0x100
#define WILD_ALLLINKS 0x200 #define WILD_ALLLINKS 0x200
#define WILD_IGNORE_COMPLETESLASH 0x400
// Flags for expand_wildcards() // Flags for expand_wildcards()
#define EW_DIR 0x01 // include directory names #define EW_DIR 0x01 // include directory names