fix: show autocmd output when F is in shortmess (#18251)

The default value of including F in 'shortmess' has the unfortunate side
effect of hiding output from autocommands. This is a common source of
confusion and often leads people to think their autocommands are not
working when they are. There is a small snippet in the docs for
'shortmess' indicating that the F flag suppresses autocmd output, but
it's not easy to find if you don't already know to look for it.

This commit removes that behavior of the F flag to make it only suppress
file info when opening a new file.
This commit is contained in:
Gregory Anders
2022-04-25 08:44:18 -06:00
committed by GitHub
parent 440b65c338
commit 2dddc86a42
8 changed files with 24 additions and 32 deletions

View File

@@ -176,7 +176,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr)
///
/// @return FAIL for failure, NOTDONE for directory (failure), or OK
int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_skip,
linenr_T lines_to_read, exarg_T *eap, int flags)
linenr_T lines_to_read, exarg_T *eap, int flags, bool silent)
{
int fd = 0;
int newfile = (flags & READ_NEW);
@@ -472,10 +472,12 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
return FAIL;
}
}
if (dir_of_file_exists(fname)) {
filemess(curbuf, sfname, (char_u *)new_file_message(), 0);
} else {
filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0);
if (!silent) {
if (dir_of_file_exists(fname)) {
filemess(curbuf, sfname, (char_u *)new_file_message(), 0);
} else {
filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0);
}
}
// Even though this is a new file, it might have been
// edited before and deleted. Get the old marks.
@@ -658,7 +660,7 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
// Autocommands may add lines to the file, need to check if it is empty
wasempty = (curbuf->b_ml.ml_flags & ML_EMPTY);
if (!recoverymode && !filtering && !(flags & READ_DUMMY)) {
if (!recoverymode && !filtering && !(flags & READ_DUMMY) && !silent) {
if (!read_stdin && !read_buffer) {
filemess(curbuf, sfname, (char_u *)"", 0);
}
@@ -1788,7 +1790,7 @@ failed:
return OK; // an interrupt isn't really an error
}
if (!filtering && !(flags & READ_DUMMY)) {
if (!filtering && !(flags & READ_DUMMY) && !silent) {
add_quoted_fname((char *)IObuff, IOSIZE, curbuf, (const char *)sfname);
c = false;
@@ -5191,7 +5193,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
curbuf->b_flags |= BF_CHECK_RO; // check for RO again
keep_filetype = true; // don't detect 'filetype'
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0,
(linenr_T)MAXLNUM, &ea, flags) != OK) {
(linenr_T)MAXLNUM, &ea, flags, false) != OK) {
if (!aborting()) {
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
}