vim-patch:7.4.1499

Problem:    No error message when :packadd does not find anything.
Solution:   Add an error message. (Hirohito Higashi)

be82c25486
This commit is contained in:
James McCoy 2016-06-20 10:12:07 -04:00
parent 85e539c996
commit 8ecdc571b0
6 changed files with 29 additions and 10 deletions

View File

@ -204,7 +204,7 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
When 'verbose' is two or higher, there is a message
about each searched file.
*:pa* *:packadd*
*:pa* *:packadd* *E919*
:pa[ckadd][!] {name} Search for an optional plugin directory in 'packpath'
and source any plugin files found. The directory must
match:

View File

@ -1850,7 +1850,7 @@ return {
},
{
command='packadd',
flags=bit.bor(BANG, FILE1, TRLBAR, SBOXOK, CMDWIN),
flags=bit.bor(BANG, FILE1, NEEDARG, TRLBAR, SBOXOK, CMDWIN),
addr_type=ADDR_LINES,
func='ex_packadd',
},

View File

@ -2277,8 +2277,7 @@ static void source_callback(char_u *fname, void *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.
/// When "flags" has DIP_DIR: find directories instead of files.
/// When "all" is true: 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 all)
@ -2288,7 +2287,16 @@ int source_runtime(char_u *name, int all)
#define DIP_ALL 1 // all matches, not just the first one
#define DIP_DIR 2 // find directories instead of files.
#define DIP_ERR 4 // give an error message when none found.
/// Find the file "name" in all directories in "path" and invoke
/// "callback(fname, cookie)".
/// "name" can contain wildcards.
/// 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_ERR: give an error message if there is no match.
///
/// return FAIL when no file could be sourced, OK otherwise.
static int do_in_path(char_u *path, char_u *name, int flags,
DoInRuntimepathCB callback, void *cookie)
{
@ -2357,10 +2365,16 @@ static int do_in_path(char_u *path, char_u *name, int flags,
}
xfree(buf);
xfree(rtp_copy);
if (p_verbose > 0 && !did_one && name != NULL) {
verbose_enter();
smsg(_("not found in 'runtimepath': \"%s\""), name);
verbose_leave();
if (!did_one && name != NULL) {
char *basepath = path == p_rtp ? "runtimepath" : "packpath";
if (flags & DIP_ERR) {
EMSG3(_(e_dirnotf), basepath, name);
} else if (p_verbose > 0) {
verbose_enter();
smsg(_("not found in '%s': \"%s\""), basepath, name);
verbose_leave();
}
}
@ -2497,7 +2511,7 @@ void ex_packadd(exarg_T *eap)
size_t len = STRLEN(plugpat) + STRLEN(eap->arg);
char *pat = (char *)xmallocz(len);
vim_snprintf(pat, len, plugpat, eap->arg);
do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR, add_pack_plugin,
do_in_path(p_pp, (char_u *)pat, DIP_ALL + DIP_DIR + DIP_ERR, add_pack_plugin,
eap->forceit ? NULL : p_pp);
xfree(pat);
}

View File

@ -1223,6 +1223,7 @@ EXTERN char_u e_invalpat[] INIT(= N_(
EXTERN char_u e_bufloaded[] INIT(= N_("E139: File is loaded in another buffer"));
EXTERN char_u e_notset[] INIT(= N_("E764: Option '%s' is not set"));
EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name"));
EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));

View File

@ -196,7 +196,7 @@ static int included_patches[] = {
// 1502 NA
// 1501 NA
1500,
// 1499,
1499,
// 1498 NA
// 1497 NA
// 1496 NA

View File

@ -45,6 +45,10 @@ describe('packadd', function()
call assert_true(17, g:ftdetect_works)
call assert_true(len(&rtp) > len(rtp))
call assert_true(&rtp =~ (s:plugdir . '\($\|,\)'))
" Check exception
call assert_fails("packadd directorynotfound", 'E919:')
call assert_fails("packadd", 'E471:')
endfunc
func Test_packadd_noload()