forked from aniani/vim
patch 9.0.1730: passing multiple patterns to runtime not working
Problem: passing multiple patterns to runtime not working Solution: prepend prefix to each argument separately closes: #12617 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
committed by
Christian Brabandt
parent
bfe377b8f2
commit
008c91537b
@@ -1312,7 +1312,7 @@ ex_helptags(exarg_T *eap)
|
|||||||
|
|
||||||
if (STRCMP(eap->arg, "ALL") == 0)
|
if (STRCMP(eap->arg, "ALL") == 0)
|
||||||
{
|
{
|
||||||
do_in_path(p_rtp, (char_u *)"doc", DIP_ALL + DIP_DIR,
|
do_in_path(p_rtp, "", (char_u *)"doc", DIP_ALL + DIP_DIR,
|
||||||
helptags_cb, &add_help_tags);
|
helptags_cb, &add_help_tags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -9,7 +9,7 @@ void ex_runtime(exarg_T *eap);
|
|||||||
void set_context_in_runtime_cmd(expand_T *xp, char_u *arg);
|
void set_context_in_runtime_cmd(expand_T *xp, char_u *arg);
|
||||||
int find_script_by_name(char_u *name);
|
int find_script_by_name(char_u *name);
|
||||||
int get_new_scriptitem_for_fname(int *error, char_u *fname);
|
int get_new_scriptitem_for_fname(int *error, char_u *fname);
|
||||||
int do_in_path(char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
|
int do_in_path(char_u *path, char *prefix, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
|
||||||
int do_in_runtimepath(char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
|
int do_in_runtimepath(char_u *name, int flags, void (*callback)(char_u *fname, void *ck), void *cookie);
|
||||||
int source_runtime(char_u *name, int flags);
|
int source_runtime(char_u *name, int flags);
|
||||||
int source_in_path(char_u *path, char_u *name, int flags, int *ret_sid);
|
int source_in_path(char_u *path, char_u *name, int flags, int *ret_sid);
|
||||||
|
@@ -404,18 +404,19 @@ find_script_callback(char_u *fname, void *cookie)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the file "name" in all directories in "path" and invoke
|
* Find the patterns in "name" in all directories in "path" and invoke
|
||||||
* "callback(fname, cookie)".
|
* "callback(fname, cookie)".
|
||||||
* "name" can contain wildcards.
|
* "prefix" is prepended to each pattern in "name".
|
||||||
* When "flags" has DIP_ALL: source all files, otherwise only the first one.
|
* When "flags" has DIP_ALL: source all files, otherwise only the first one.
|
||||||
* When "flags" has DIP_DIR: find directories instead of files.
|
* When "flags" has DIP_DIR: find directories instead of files.
|
||||||
* When "flags" has DIP_ERR: give an error message if there is no match.
|
* When "flags" has DIP_ERR: give an error message if there is no match.
|
||||||
*
|
*
|
||||||
* return FAIL when no file could be sourced, OK otherwise.
|
* Return FAIL when no file could be sourced, OK otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
do_in_path(
|
do_in_path(
|
||||||
char_u *path,
|
char_u *path,
|
||||||
|
char *prefix,
|
||||||
char_u *name,
|
char_u *name,
|
||||||
int flags,
|
int flags,
|
||||||
void (*callback)(char_u *fname, void *ck),
|
void (*callback)(char_u *fname, void *ck),
|
||||||
@@ -447,6 +448,10 @@ do_in_path(
|
|||||||
if (p_verbose > 10 && name != NULL)
|
if (p_verbose > 10 && name != NULL)
|
||||||
{
|
{
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
|
if (*prefix != NUL)
|
||||||
|
smsg(_("Searching for \"%s\" under \"%s\" in \"%s\""),
|
||||||
|
(char *)name, prefix, (char *)path);
|
||||||
|
else
|
||||||
smsg(_("Searching for \"%s\" in \"%s\""),
|
smsg(_("Searching for \"%s\" in \"%s\""),
|
||||||
(char *)name, (char *)path);
|
(char *)name, (char *)path);
|
||||||
verbose_leave();
|
verbose_leave();
|
||||||
@@ -479,9 +484,10 @@ do_in_path(
|
|||||||
if (!did_one)
|
if (!did_one)
|
||||||
did_one = (cookie == NULL);
|
did_one = (cookie == NULL);
|
||||||
}
|
}
|
||||||
else if (buflen + STRLEN(name) + 2 < MAXPATHL)
|
else if (buflen + 2 + STRLEN(prefix) + STRLEN(name) < MAXPATHL)
|
||||||
{
|
{
|
||||||
add_pathsep(buf);
|
add_pathsep(buf);
|
||||||
|
STRCAT(buf, prefix);
|
||||||
tail = buf + STRLEN(buf);
|
tail = buf + STRLEN(buf);
|
||||||
|
|
||||||
// Loop over all patterns in "name"
|
// Loop over all patterns in "name"
|
||||||
@@ -559,35 +565,17 @@ do_in_path_and_pp(
|
|||||||
void *cookie)
|
void *cookie)
|
||||||
{
|
{
|
||||||
int done = FAIL;
|
int done = FAIL;
|
||||||
char_u *s;
|
|
||||||
int len;
|
|
||||||
char *start_dir = "pack/*/start/*/%s";
|
|
||||||
char *opt_dir = "pack/*/opt/*/%s";
|
|
||||||
|
|
||||||
if ((flags & DIP_NORTP) == 0)
|
if ((flags & DIP_NORTP) == 0)
|
||||||
done = do_in_path(path, name, flags, callback, cookie);
|
done = do_in_path(path, "", name, flags, callback, cookie);
|
||||||
|
|
||||||
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START))
|
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START))
|
||||||
{
|
done = do_in_path(p_pp, "pack/*/start/*/", name, flags, callback,
|
||||||
len = (int)(STRLEN(start_dir) + STRLEN(name));
|
cookie);
|
||||||
s = alloc(len);
|
|
||||||
if (s == NULL)
|
|
||||||
return FAIL;
|
|
||||||
vim_snprintf((char *)s, len, start_dir, name);
|
|
||||||
done = do_in_path(p_pp, s, flags, callback, cookie);
|
|
||||||
vim_free(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT))
|
if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_OPT))
|
||||||
{
|
done = do_in_path(p_pp, "pack/*/opt/*/", name, flags, callback,
|
||||||
len = (int)(STRLEN(opt_dir) + STRLEN(name));
|
cookie);
|
||||||
s = alloc(len);
|
|
||||||
if (s == NULL)
|
|
||||||
return FAIL;
|
|
||||||
vim_snprintf((char *)s, len, opt_dir, name);
|
|
||||||
done = do_in_path(p_pp, s, flags, callback, cookie);
|
|
||||||
vim_free(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
@@ -899,7 +887,7 @@ add_pack_plugin(char_u *fname, void *cookie)
|
|||||||
void
|
void
|
||||||
add_pack_start_dirs(void)
|
add_pack_start_dirs(void)
|
||||||
{
|
{
|
||||||
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
|
do_in_path(p_pp, "", (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
|
||||||
add_pack_plugin, &APP_ADD_DIR);
|
add_pack_plugin, &APP_ADD_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,7 +898,7 @@ add_pack_start_dirs(void)
|
|||||||
load_start_packages(void)
|
load_start_packages(void)
|
||||||
{
|
{
|
||||||
did_source_packages = TRUE;
|
did_source_packages = TRUE;
|
||||||
do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
|
do_in_path(p_pp, "", (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR,
|
||||||
add_pack_plugin, &APP_LOAD);
|
add_pack_plugin, &APP_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -957,7 +945,7 @@ ex_packadd(exarg_T *eap)
|
|||||||
vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg);
|
vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg);
|
||||||
// The first round don't give a "not found" error, in the second round
|
// The first round don't give a "not found" error, in the second round
|
||||||
// only when nothing was found in the first round.
|
// only when nothing was found in the first round.
|
||||||
res = do_in_path(p_pp, (char_u *)pat,
|
res = do_in_path(p_pp, "", (char_u *)pat,
|
||||||
DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
|
DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
|
||||||
add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
|
add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
|
||||||
vim_free(pat);
|
vim_free(pat);
|
||||||
|
@@ -346,12 +346,36 @@ func Test_runtime()
|
|||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime extra/bar.vim
|
runtime extra/bar.vim
|
||||||
call assert_equal('run', g:sequence)
|
call assert_equal('run', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime NoSuchFile extra/bar.vim
|
||||||
|
call assert_equal('run', g:sequence)
|
||||||
|
|
||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime START extra/bar.vim
|
runtime START extra/bar.vim
|
||||||
call assert_equal('start', g:sequence)
|
call assert_equal('start', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime START NoSuchFile extra/bar.vim extra/foo.vim
|
||||||
|
call assert_equal('start', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime START NoSuchFile extra/foo.vim extra/bar.vim
|
||||||
|
call assert_equal('foostart', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime! START NoSuchFile extra/bar.vim extra/foo.vim
|
||||||
|
call assert_equal('startfoostart', g:sequence)
|
||||||
|
|
||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime OPT extra/bar.vim
|
runtime OPT extra/bar.vim
|
||||||
call assert_equal('opt', g:sequence)
|
call assert_equal('opt', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime OPT NoSuchFile extra/bar.vim extra/xxx.vim
|
||||||
|
call assert_equal('opt', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime OPT NoSuchFile extra/xxx.vim extra/bar.vim
|
||||||
|
call assert_equal('xxxopt', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime! OPT NoSuchFile extra/bar.vim extra/xxx.vim
|
||||||
|
call assert_equal('optxxxopt', g:sequence)
|
||||||
|
|
||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime PACK extra/bar.vim
|
runtime PACK extra/bar.vim
|
||||||
call assert_equal('start', g:sequence)
|
call assert_equal('start', g:sequence)
|
||||||
@@ -361,6 +385,12 @@ func Test_runtime()
|
|||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime PACK extra/xxx.vim
|
runtime PACK extra/xxx.vim
|
||||||
call assert_equal('xxxopt', g:sequence)
|
call assert_equal('xxxopt', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime PACK extra/xxx.vim extra/foo.vim extra/bar.vim
|
||||||
|
call assert_equal('foostart', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime! PACK extra/bar.vim extra/xxx.vim extra/foo.vim
|
||||||
|
call assert_equal('startfoostartoptxxxopt', g:sequence)
|
||||||
|
|
||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime ALL extra/bar.vim
|
runtime ALL extra/bar.vim
|
||||||
@@ -374,6 +404,12 @@ func Test_runtime()
|
|||||||
let g:sequence = ''
|
let g:sequence = ''
|
||||||
runtime! ALL extra/bar.vim
|
runtime! ALL extra/bar.vim
|
||||||
call assert_equal('runstartopt', g:sequence)
|
call assert_equal('runstartopt', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime ALL extra/xxx.vim extra/foo.vim extra/bar.vim
|
||||||
|
call assert_equal('run', g:sequence)
|
||||||
|
let g:sequence = ''
|
||||||
|
runtime! ALL extra/bar.vim extra/xxx.vim extra/foo.vim
|
||||||
|
call assert_equal('runstartfoostartoptxxxopt', g:sequence)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_runtime_completion()
|
func Test_runtime_completion()
|
||||||
|
@@ -695,6 +695,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 */
|
||||||
|
/**/
|
||||||
|
1730,
|
||||||
/**/
|
/**/
|
||||||
1729,
|
1729,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user