Skip to content

Commit e201ce7

Browse files
committed
updated for version 7.3.237
Problem: "filetype" completion doesn't work on Windows. (Yue Wu) Solution: Don't use a glob pattern for the directories, use a list of directories. (Dominique Pelle)
1 parent 28aab09 commit e201ce7

File tree

2 files changed

+60
-35
lines changed

2 files changed

+60
-35
lines changed

src/ex_getln.c

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int ExpandFromContext __ARGS((expand_T *xp, char_u *, int *, char_u ***,
110110
static int expand_showtail __ARGS((expand_T *xp));
111111
#ifdef FEAT_CMDL_COMPL
112112
static int expand_shellcmd __ARGS((char_u *filepat, int *num_file, char_u ***file, int flagsarg));
113-
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname));
113+
static int ExpandRTDir __ARGS((char_u *pat, int *num_file, char_u ***file, char *dirname[]));
114114
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
115115
static int ExpandUserDefined __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
116116
static int ExpandUserList __ARGS((expand_T *xp, int *num_file, char_u ***file));
@@ -4536,13 +4536,25 @@ ExpandFromContext(xp, pat, num_file, file, options)
45364536
|| xp->xp_context == EXPAND_TAGS_LISTFILES)
45374537
return expand_tags(xp->xp_context == EXPAND_TAGS, pat, num_file, file);
45384538
if (xp->xp_context == EXPAND_COLORS)
4539-
return ExpandRTDir(pat, num_file, file, "colors");
4539+
{
4540+
char *directories[] = {"colors", NULL};
4541+
return ExpandRTDir(pat, num_file, file, directories);
4542+
}
45404543
if (xp->xp_context == EXPAND_COMPILER)
4541-
return ExpandRTDir(pat, num_file, file, "compiler");
4544+
{
4545+
char *directories[] = {"colors", NULL};
4546+
return ExpandRTDir(pat, num_file, file, directories);
4547+
}
45424548
if (xp->xp_context == EXPAND_OWNSYNTAX)
4543-
return ExpandRTDir(pat, num_file, file, "syntax");
4549+
{
4550+
char *directories[] = {"syntax", NULL};
4551+
return ExpandRTDir(pat, num_file, file, directories);
4552+
}
45444553
if (xp->xp_context == EXPAND_FILETYPE)
4545-
return ExpandRTDir(pat, num_file, file, "{syntax,indent,ftplugin}");
4554+
{
4555+
char *directories[] = {"syntax", "indent", "ftplugin", NULL};
4556+
return ExpandRTDir(pat, num_file, file, directories);
4557+
}
45464558
# if defined(FEAT_USR_CMDS) && defined(FEAT_EVAL)
45474559
if (xp->xp_context == EXPAND_USER_LIST)
45484560
return ExpandUserList(xp, num_file, file);
@@ -4995,57 +5007,68 @@ ExpandUserList(xp, num_file, file)
49955007
/*
49965008
* Expand color scheme, compiler or filetype names:
49975009
* 'runtimepath'/{dirnames}/{pat}.vim
4998-
* dirnames may contain one directory (ex: "colorscheme") or can be a glob
4999-
* expression matching multiple directories (ex: "{syntax,ftplugin,indent}").
5010+
* "dirnames" is an array with one or more directory names.
50005011
*/
50015012
static int
50025013
ExpandRTDir(pat, num_file, file, dirnames)
50035014
char_u *pat;
50045015
int *num_file;
50055016
char_u ***file;
5006-
char *dirnames;
5017+
char *dirnames[];
50075018
{
5008-
char_u *all;
5019+
char_u *matches;
50095020
char_u *s;
50105021
char_u *e;
50115022
garray_T ga;
5023+
int i;
5024+
int pat_len;
50125025

50135026
*num_file = 0;
50145027
*file = NULL;
5015-
s = alloc((unsigned)(STRLEN(pat) + STRLEN(dirnames) + 7));
5016-
if (s == NULL)
5017-
return FAIL;
5018-
sprintf((char *)s, "%s/%s*.vim", dirnames, pat);
5019-
all = globpath(p_rtp, s, 0);
5020-
vim_free(s);
5021-
if (all == NULL)
5022-
return FAIL;
5028+
pat_len = STRLEN(pat);
5029+
ga_init2(&ga, (int)sizeof(char *), 10);
50235030

5024-
ga_init2(&ga, (int)sizeof(char *), 3);
5025-
for (s = all; *s != NUL; s = e)
5031+
for (i = 0; dirnames[i] != NULL; ++i)
50265032
{
5027-
e = vim_strchr(s, '\n');
5028-
if (e == NULL)
5029-
e = s + STRLEN(s);
5030-
if (ga_grow(&ga, 1) == FAIL)
5031-
break;
5032-
if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0)
5033+
s = alloc((unsigned)(STRLEN(dirnames[i]) + pat_len + 7));
5034+
if (s == NULL)
50335035
{
5034-
for (s = e - 4; s > all; mb_ptr_back(all, s))
5035-
if (*s == '\n' || vim_ispathsep(*s))
5036-
break;
5037-
++s;
5038-
((char_u **)ga.ga_data)[ga.ga_len] =
5036+
ga_clear_strings(&ga);
5037+
return FAIL;
5038+
}
5039+
sprintf((char *)s, "%s/%s*.vim", dirnames[i], pat);
5040+
matches = globpath(p_rtp, s, 0);
5041+
vim_free(s);
5042+
if (matches == NULL)
5043+
continue;
5044+
5045+
for (s = matches; *s != NUL; s = e)
5046+
{
5047+
e = vim_strchr(s, '\n');
5048+
if (e == NULL)
5049+
e = s + STRLEN(s);
5050+
if (ga_grow(&ga, 1) == FAIL)
5051+
break;
5052+
if (e - 4 > s && STRNICMP(e - 4, ".vim", 4) == 0)
5053+
{
5054+
for (s = e - 4; s > matches; mb_ptr_back(matches, s))
5055+
if (*s == '\n' || vim_ispathsep(*s))
5056+
break;
5057+
++s;
5058+
((char_u **)ga.ga_data)[ga.ga_len] =
50395059
vim_strnsave(s, (int)(e - s - 4));
5040-
++ga.ga_len;
5060+
++ga.ga_len;
5061+
}
5062+
if (*e != NUL)
5063+
++e;
50415064
}
5042-
if (*e != NUL)
5043-
++e;
5065+
vim_free(matches);
50445066
}
5045-
vim_free(all);
5067+
if (ga.ga_len == 0)
5068+
return FAIL;
50465069

50475070
/* Sort and remove duplicates which can happen when specifying multiple
5048-
* directories in dirnames such as "{syntax,ftplugin,indent}". */
5071+
* directories in dirnames. */
50495072
remove_duplicates(&ga);
50505073

50515074
*file = ga.ga_data;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ static char *(features[]) =
709709

710710
static int included_patches[] =
711711
{ /* Add new patch number below this line */
712+
/**/
713+
237,
712714
/**/
713715
236,
714716
/**/

0 commit comments

Comments
 (0)