summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds2.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-17 14:26:46 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-17 14:26:46 +0100
commit9e1d399e63903c6f84d7888ad8d84ebf4e29d8a1 (patch)
tree9f53ab0a76bcc0a8c7f05e3863f724fc126e89a0 /src/ex_cmds2.c
parent890dd05492d88d48eee1dda7f7a1811d027ce7ca (diff)
patch 8.0.1398: :packadd does not load packages from the "start" directoryv8.0.1398
Problem: :packadd does not load packages from the "start" directory. (Alejandro Hernandez) Solution: Make :packadd look in the "start" directory if those packages were not loaded on startup.
Diffstat (limited to 'src/ex_cmds2.c')
-rw-r--r--src/ex_cmds2.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 7b00ac2650..1475ef25db 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -3747,18 +3747,31 @@ ex_packloadall(exarg_T *eap)
void
ex_packadd(exarg_T *eap)
{
- static char *plugpat = "pack/*/opt/%s";
+ static char *plugpat = "pack/*/%s/%s";
int len;
char *pat;
+ int round;
+ int res = OK;
- len = (int)STRLEN(plugpat) + (int)STRLEN(eap->arg);
- pat = (char *)alloc(len);
- if (pat == NULL)
- return;
- vim_snprintf(pat, len, plugpat, eap->arg);
- do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR,
- add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
- vim_free(pat);
+ /* Round 1: use "start", round 2: use "opt". */
+ for (round = 1; round <= 2; ++round)
+ {
+ /* Only look under "start" when loading packages wasn't done yet. */
+ if (round == 1 && did_source_packages)
+ continue;
+
+ len = (int)STRLEN(plugpat) + (int)STRLEN(eap->arg) + 5;
+ pat = (char *)alloc(len);
+ if (pat == NULL)
+ return;
+ 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
+ * only when nothing was found in the first round. */
+ res = do_in_path(p_pp, (char_u *)pat,
+ DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
+ add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
+ vim_free(pat);
+ }
}
#if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD)