comparison src/ex_cmds2.c @ 13045:afd60028f7b7 v8.0.1398

patch 8.0.1398: :packadd does not load packages from the "start" directory commit https://github.com/vim/vim/commit/9e1d399e63903c6f84d7888ad8d84ebf4e29d8a1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Dec 17 14:26:46 2017 +0100 patch 8.0.1398: :packadd does not load packages from the "start" directory 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.
author Christian Brabandt <cb@256bit.org>
date Sun, 17 Dec 2017 14:30:06 +0100
parents 5532b5176870
children 9fccd578ce1f
comparison
equal deleted inserted replaced
13044:0edbace95f0f 13045:afd60028f7b7
3745 * ":packadd[!] {name}" 3745 * ":packadd[!] {name}"
3746 */ 3746 */
3747 void 3747 void
3748 ex_packadd(exarg_T *eap) 3748 ex_packadd(exarg_T *eap)
3749 { 3749 {
3750 static char *plugpat = "pack/*/opt/%s"; 3750 static char *plugpat = "pack/*/%s/%s";
3751 int len; 3751 int len;
3752 char *pat; 3752 char *pat;
3753 3753 int round;
3754 len = (int)STRLEN(plugpat) + (int)STRLEN(eap->arg); 3754 int res = OK;
3755 pat = (char *)alloc(len); 3755
3756 if (pat == NULL) 3756 /* Round 1: use "start", round 2: use "opt". */
3757 return; 3757 for (round = 1; round <= 2; ++round)
3758 vim_snprintf(pat, len, plugpat, eap->arg); 3758 {
3759 do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, 3759 /* Only look under "start" when loading packages wasn't done yet. */
3760 add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH); 3760 if (round == 1 && did_source_packages)
3761 vim_free(pat); 3761 continue;
3762
3763 len = (int)STRLEN(plugpat) + (int)STRLEN(eap->arg) + 5;
3764 pat = (char *)alloc(len);
3765 if (pat == NULL)
3766 return;
3767 vim_snprintf(pat, len, plugpat, round == 1 ? "start" : "opt", eap->arg);
3768 /* The first round don't give a "not found" error, in the second round
3769 * only when nothing was found in the first round. */
3770 res = do_in_path(p_pp, (char_u *)pat,
3771 DIP_ALL + DIP_DIR + (round == 2 && res == FAIL ? DIP_ERR : 0),
3772 add_pack_plugin, eap->forceit ? &APP_ADD_DIR : &APP_BOTH);
3773 vim_free(pat);
3774 }
3762 } 3775 }
3763 3776
3764 #if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD) 3777 #if defined(FEAT_EVAL) && defined(FEAT_AUTOCMD)
3765 /* 3778 /*
3766 * ":options" 3779 * ":options"