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

@@ -109,6 +109,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
{
int retval = OK;
linenr_T line_count;
bool silent = shortmess(SHM_FILEINFO);
// Read from the buffer which the text is already filled in and append at
// the end. This makes it possible to retry when 'fileformat' or
@@ -117,7 +118,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
retval = readfile(read_stdin ? NULL : curbuf->b_ffname,
read_stdin ? NULL : curbuf->b_fname,
line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_BUFFER);
flags | READ_BUFFER, silent);
if (retval == OK) {
// Delete the binary lines.
while (--line_count >= 0) {
@@ -162,6 +163,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
bufref_T old_curbuf;
long old_tw = curbuf->b_p_tw;
int read_fifo = false;
bool silent = shortmess(SHM_FILEINFO);
// The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
// When re-entering the same buffer, it should not change, because the
@@ -212,7 +214,6 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
curwin->w_valid = 0;
if (curbuf->b_ffname != NULL) {
int old_msg_silent = msg_silent;
#ifdef UNIX
int save_bin = curbuf->b_p_bin;
int perm;
@@ -231,13 +232,10 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
curbuf->b_p_bin = true;
}
#endif
if (shortmess(SHM_FILEINFO)) {
msg_silent = 1;
}
retval = readfile(curbuf->b_ffname, curbuf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap,
flags | READ_NEW | (read_fifo ? READ_FIFO : 0));
flags | READ_NEW | (read_fifo ? READ_FIFO : 0), silent);
#ifdef UNIX
if (read_fifo) {
curbuf->b_p_bin = save_bin;
@@ -246,7 +244,6 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
}
}
#endif
msg_silent = old_msg_silent;
// Help buffer is filtered.
if (bt_help(curbuf)) {
@@ -262,7 +259,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
curbuf->b_p_bin = true;
retval = readfile(NULL, NULL, (linenr_T)0,
(linenr_T)0, (linenr_T)MAXLNUM, NULL,
flags | (READ_NEW + READ_STDIN));
flags | (READ_NEW + READ_STDIN), silent);
curbuf->b_p_bin = save_bin;
if (retval == OK) {
retval = read_buffer(true, eap, flags);
@@ -903,14 +900,7 @@ void handle_swap_exists(bufref_T *old_curbuf)
buf = old_curbuf->br_buf;
}
if (buf != NULL) {
int old_msg_silent = msg_silent;
if (shortmess(SHM_FILEINFO)) {
msg_silent = 1; // prevent fileinfo message
}
enter_buffer(buf);
// restore msg_silent, so that the command line will be shown
msg_silent = old_msg_silent;
if (old_tw != curbuf->b_p_tw) {
check_colorcolumn(curwin);
@@ -5611,7 +5601,7 @@ bool buf_contents_changed(buf_T *buf)
if (ml_open(curbuf) == OK
&& readfile(buf->b_ffname, buf->b_fname,
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
&ea, READ_NEW | READ_DUMMY) == OK) {
&ea, READ_NEW | READ_DUMMY, false) == OK) {
// compare the two files line by line
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) {
differ = false;