From 07ecfa64a18609a986f21d6132d04ee8934f3200 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 27 Jun 2017 14:43:55 +0200 Subject: patch 8.0.0680: plugins in start packages are sourced twice Problem: Plugins in start packages are sourced twice. (mseplowitz) Solution: Use the unmodified runtime path when loading plugins (test by Ingo Karkat, closes #1801) --- src/ex_cmds2.c | 60 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 18 deletions(-) (limited to 'src/ex_cmds2.c') diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 33ad924d22..74dae92b5b 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -3285,19 +3285,6 @@ source_callback(char_u *fname, void *cookie UNUSED) (void)do_source(fname, FALSE, DOSO_NONE); } -/* - * Source the file "name" from all directories in 'runtimepath'. - * "name" can contain wildcards. - * When "flags" has DIP_ALL: source all files, otherwise only the first one. - * - * return FAIL when no file could be sourced, OK otherwise. - */ - int -source_runtime(char_u *name, int flags) -{ - return do_in_runtimepath(name, flags, source_callback, NULL); -} - /* * Find the file "name" in all directories in "path" and invoke * "callback(fname, cookie)". @@ -3435,18 +3422,19 @@ do_in_path( } /* - * Find "name" in 'runtimepath'. When found, invoke the callback function for + * Find "name" in "path". When found, invoke the callback function for * it: callback(fname, "cookie") * When "flags" has DIP_ALL repeat for all matches, otherwise only the first * one is used. * Returns OK when at least one match found, FAIL otherwise. * - * If "name" is NULL calls callback for each entry in runtimepath. Cookie is + * If "name" is NULL calls callback for each entry in "path". Cookie is * passed by reference in this case, setting it to NULL indicates that callback * has done its job. */ - int -do_in_runtimepath( + static int +do_in_path_and_pp( + char_u *path, char_u *name, int flags, void (*callback)(char_u *fname, void *ck), @@ -3459,7 +3447,7 @@ do_in_runtimepath( char *opt_dir = "pack/*/opt/*/%s"; if ((flags & DIP_NORTP) == 0) - done = do_in_path(p_rtp, name, flags, callback, cookie); + done = do_in_path(path, name, flags, callback, cookie); if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { @@ -3486,6 +3474,42 @@ do_in_runtimepath( return done; } +/* + * Just like do_in_path_and_pp(), using 'runtimepath' for "path". + */ + int +do_in_runtimepath( + char_u *name, + int flags, + void (*callback)(char_u *fname, void *ck), + void *cookie) +{ + return do_in_path_and_pp(p_rtp, name, flags, callback, cookie); +} + +/* + * Source the file "name" from all directories in 'runtimepath'. + * "name" can contain wildcards. + * When "flags" has DIP_ALL: source all files, otherwise only the first one. + * + * return FAIL when no file could be sourced, OK otherwise. + */ + int +source_runtime(char_u *name, int flags) +{ + return source_in_path(p_rtp, name, flags); +} + +/* + * Just like source_runtime(), but use "path" instead of 'runtimepath'. + */ + int +source_in_path(char_u *path, char_u *name, int flags) +{ + return do_in_path_and_pp(path, name, flags, source_callback, NULL); +} + + /* * Expand wildcards in "pat" and invoke do_source() for each match. */ -- cgit v1.2.3