mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
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:
@@ -5532,8 +5532,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
"Pattern not found", "Back at original", etc.
|
"Pattern not found", "Back at original", etc.
|
||||||
q use "recording" instead of "recording @a"
|
q use "recording" instead of "recording @a"
|
||||||
F don't give the file info when editing a file, like `:silent`
|
F don't give the file info when editing a file, like `:silent`
|
||||||
was used for the command; note that this also affects messages
|
was used for the command
|
||||||
from autocommands
|
|
||||||
S do not show search count message when searching, e.g.
|
S do not show search count message when searching, e.g.
|
||||||
"[1/5]"
|
"[1/5]"
|
||||||
|
|
||||||
|
@@ -375,6 +375,7 @@ Normal commands:
|
|||||||
Options:
|
Options:
|
||||||
'ttimeout', 'ttimeoutlen' behavior was simplified
|
'ttimeout', 'ttimeoutlen' behavior was simplified
|
||||||
|jumpoptions| "stack" behavior
|
|jumpoptions| "stack" behavior
|
||||||
|
'shortmess' the "F" flag does not affect output from autocommands
|
||||||
|
|
||||||
Shell:
|
Shell:
|
||||||
Shell output (|:!|, |:make|, …) is always routed through the UI, so it
|
Shell output (|:!|, |:make|, …) is always routed through the UI, so it
|
||||||
|
@@ -109,6 +109,7 @@ static int read_buffer(int read_stdin, exarg_T *eap, int flags)
|
|||||||
{
|
{
|
||||||
int retval = OK;
|
int retval = OK;
|
||||||
linenr_T line_count;
|
linenr_T line_count;
|
||||||
|
bool silent = shortmess(SHM_FILEINFO);
|
||||||
|
|
||||||
// Read from the buffer which the text is already filled in and append at
|
// 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
|
// 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,
|
retval = readfile(read_stdin ? NULL : curbuf->b_ffname,
|
||||||
read_stdin ? NULL : curbuf->b_fname,
|
read_stdin ? NULL : curbuf->b_fname,
|
||||||
line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
|
line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap,
|
||||||
flags | READ_BUFFER);
|
flags | READ_BUFFER, silent);
|
||||||
if (retval == OK) {
|
if (retval == OK) {
|
||||||
// Delete the binary lines.
|
// Delete the binary lines.
|
||||||
while (--line_count >= 0) {
|
while (--line_count >= 0) {
|
||||||
@@ -162,6 +163,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
|
|||||||
bufref_T old_curbuf;
|
bufref_T old_curbuf;
|
||||||
long old_tw = curbuf->b_p_tw;
|
long old_tw = curbuf->b_p_tw;
|
||||||
int read_fifo = false;
|
int read_fifo = false;
|
||||||
|
bool silent = shortmess(SHM_FILEINFO);
|
||||||
|
|
||||||
// The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
|
// The 'readonly' flag is only set when BF_NEVERLOADED is being reset.
|
||||||
// When re-entering the same buffer, it should not change, because the
|
// 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;
|
curwin->w_valid = 0;
|
||||||
|
|
||||||
if (curbuf->b_ffname != NULL) {
|
if (curbuf->b_ffname != NULL) {
|
||||||
int old_msg_silent = msg_silent;
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
int save_bin = curbuf->b_p_bin;
|
int save_bin = curbuf->b_p_bin;
|
||||||
int perm;
|
int perm;
|
||||||
@@ -231,13 +232,10 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
|
|||||||
curbuf->b_p_bin = true;
|
curbuf->b_p_bin = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (shortmess(SHM_FILEINFO)) {
|
|
||||||
msg_silent = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = readfile(curbuf->b_ffname, curbuf->b_fname,
|
retval = readfile(curbuf->b_ffname, curbuf->b_fname,
|
||||||
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap,
|
(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
|
#ifdef UNIX
|
||||||
if (read_fifo) {
|
if (read_fifo) {
|
||||||
curbuf->b_p_bin = save_bin;
|
curbuf->b_p_bin = save_bin;
|
||||||
@@ -246,7 +244,6 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
msg_silent = old_msg_silent;
|
|
||||||
|
|
||||||
// Help buffer is filtered.
|
// Help buffer is filtered.
|
||||||
if (bt_help(curbuf)) {
|
if (bt_help(curbuf)) {
|
||||||
@@ -262,7 +259,7 @@ int open_buffer(int read_stdin, exarg_T *eap, int flags)
|
|||||||
curbuf->b_p_bin = true;
|
curbuf->b_p_bin = true;
|
||||||
retval = readfile(NULL, NULL, (linenr_T)0,
|
retval = readfile(NULL, NULL, (linenr_T)0,
|
||||||
(linenr_T)0, (linenr_T)MAXLNUM, NULL,
|
(linenr_T)0, (linenr_T)MAXLNUM, NULL,
|
||||||
flags | (READ_NEW + READ_STDIN));
|
flags | (READ_NEW + READ_STDIN), silent);
|
||||||
curbuf->b_p_bin = save_bin;
|
curbuf->b_p_bin = save_bin;
|
||||||
if (retval == OK) {
|
if (retval == OK) {
|
||||||
retval = read_buffer(true, eap, flags);
|
retval = read_buffer(true, eap, flags);
|
||||||
@@ -903,14 +900,7 @@ void handle_swap_exists(bufref_T *old_curbuf)
|
|||||||
buf = old_curbuf->br_buf;
|
buf = old_curbuf->br_buf;
|
||||||
}
|
}
|
||||||
if (buf != NULL) {
|
if (buf != NULL) {
|
||||||
int old_msg_silent = msg_silent;
|
|
||||||
|
|
||||||
if (shortmess(SHM_FILEINFO)) {
|
|
||||||
msg_silent = 1; // prevent fileinfo message
|
|
||||||
}
|
|
||||||
enter_buffer(buf);
|
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) {
|
if (old_tw != curbuf->b_p_tw) {
|
||||||
check_colorcolumn(curwin);
|
check_colorcolumn(curwin);
|
||||||
@@ -5611,7 +5601,7 @@ bool buf_contents_changed(buf_T *buf)
|
|||||||
if (ml_open(curbuf) == OK
|
if (ml_open(curbuf) == OK
|
||||||
&& readfile(buf->b_ffname, buf->b_fname,
|
&& readfile(buf->b_ffname, buf->b_fname,
|
||||||
(linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM,
|
(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
|
// compare the two files line by line
|
||||||
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) {
|
if (buf->b_ml.ml_line_count == curbuf->b_ml.ml_line_count) {
|
||||||
differ = false;
|
differ = false;
|
||||||
|
@@ -1387,7 +1387,7 @@ static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, char_u *cmd,
|
|||||||
if (do_out) {
|
if (do_out) {
|
||||||
if (otmp != NULL) {
|
if (otmp != NULL) {
|
||||||
if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap,
|
if (readfile(otmp, NULL, line2, (linenr_T)0, (linenr_T)MAXLNUM, eap,
|
||||||
READ_FILTER) != OK) {
|
READ_FILTER, false) != OK) {
|
||||||
if (!aborting()) {
|
if (!aborting()) {
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
semsg(_(e_notread), otmp);
|
semsg(_(e_notread), otmp);
|
||||||
|
@@ -7702,13 +7702,13 @@ static void ex_read(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i = readfile(curbuf->b_ffname, curbuf->b_fname,
|
i = readfile(curbuf->b_ffname, curbuf->b_fname,
|
||||||
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
|
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
|
||||||
} else {
|
} else {
|
||||||
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
|
if (vim_strchr(p_cpo, CPO_ALTREAD) != NULL) {
|
||||||
(void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
|
(void)setaltfname(eap->arg, eap->arg, (linenr_T)1);
|
||||||
}
|
}
|
||||||
i = readfile(eap->arg, NULL,
|
i = readfile(eap->arg, NULL,
|
||||||
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0);
|
eap->line2, (linenr_T)0, (linenr_T)MAXLNUM, eap, 0, false);
|
||||||
}
|
}
|
||||||
if (i != OK) {
|
if (i != OK) {
|
||||||
if (!aborting()) {
|
if (!aborting()) {
|
||||||
|
@@ -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
|
/// @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,
|
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 fd = 0;
|
||||||
int newfile = (flags & READ_NEW);
|
int newfile = (flags & READ_NEW);
|
||||||
@@ -472,11 +472,13 @@ int readfile(char_u *fname, char_u *sfname, linenr_T from, linenr_T lines_to_ski
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!silent) {
|
||||||
if (dir_of_file_exists(fname)) {
|
if (dir_of_file_exists(fname)) {
|
||||||
filemess(curbuf, sfname, (char_u *)new_file_message(), 0);
|
filemess(curbuf, sfname, (char_u *)new_file_message(), 0);
|
||||||
} else {
|
} else {
|
||||||
filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0);
|
filemess(curbuf, sfname, (char_u *)_("[New DIRECTORY]"), 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Even though this is a new file, it might have been
|
// Even though this is a new file, it might have been
|
||||||
// edited before and deleted. Get the old marks.
|
// edited before and deleted. Get the old marks.
|
||||||
check_marks_read();
|
check_marks_read();
|
||||||
@@ -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
|
// Autocommands may add lines to the file, need to check if it is empty
|
||||||
wasempty = (curbuf->b_ml.ml_flags & ML_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) {
|
if (!read_stdin && !read_buffer) {
|
||||||
filemess(curbuf, sfname, (char_u *)"", 0);
|
filemess(curbuf, sfname, (char_u *)"", 0);
|
||||||
}
|
}
|
||||||
@@ -1788,7 +1790,7 @@ failed:
|
|||||||
return OK; // an interrupt isn't really an error
|
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);
|
add_quoted_fname((char *)IObuff, IOSIZE, curbuf, (const char *)sfname);
|
||||||
c = false;
|
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
|
curbuf->b_flags |= BF_CHECK_RO; // check for RO again
|
||||||
keep_filetype = true; // don't detect 'filetype'
|
keep_filetype = true; // don't detect 'filetype'
|
||||||
if (readfile(buf->b_ffname, buf->b_fname, (linenr_T)0, (linenr_T)0,
|
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()) {
|
if (!aborting()) {
|
||||||
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
|
semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
|
||||||
}
|
}
|
||||||
|
@@ -994,7 +994,7 @@ void ml_recover(bool checkext)
|
|||||||
*/
|
*/
|
||||||
if (curbuf->b_ffname != NULL) {
|
if (curbuf->b_ffname != NULL) {
|
||||||
orig_file_status = readfile(curbuf->b_ffname, NULL, (linenr_T)0,
|
orig_file_status = readfile(curbuf->b_ffname, NULL, (linenr_T)0,
|
||||||
(linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW);
|
(linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the 'fileformat' and 'fileencoding' as stored in the swap file.
|
// Use the 'fileformat' and 'fileencoding' as stored in the swap file.
|
||||||
@@ -1069,7 +1069,7 @@ void ml_recover(bool checkext)
|
|||||||
line_count = pp->pb_pointer[idx].pe_line_count;
|
line_count = pp->pb_pointer[idx].pe_line_count;
|
||||||
if (readfile(curbuf->b_ffname, NULL, lnum,
|
if (readfile(curbuf->b_ffname, NULL, lnum,
|
||||||
pp->pb_pointer[idx].pe_old_lnum - 1, line_count,
|
pp->pb_pointer[idx].pe_old_lnum - 1, line_count,
|
||||||
NULL, 0) != OK) {
|
NULL, 0, false) != OK) {
|
||||||
cannot_open = true;
|
cannot_open = true;
|
||||||
} else {
|
} else {
|
||||||
lnum += line_count;
|
lnum += line_count;
|
||||||
|
@@ -5753,7 +5753,7 @@ static buf_T *load_dummy_buffer(char_u *fname, char_u *dirname_start, char_u *re
|
|||||||
newbuf_to_wipe.br_buf = NULL;
|
newbuf_to_wipe.br_buf = NULL;
|
||||||
readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0,
|
readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0,
|
||||||
(linenr_T)MAXLNUM, NULL,
|
(linenr_T)MAXLNUM, NULL,
|
||||||
READ_NEW | READ_DUMMY);
|
READ_NEW | READ_DUMMY, false);
|
||||||
newbuf->b_locked--;
|
newbuf->b_locked--;
|
||||||
if (readfile_result == OK
|
if (readfile_result == OK
|
||||||
&& !got_int
|
&& !got_int
|
||||||
|
Reference in New Issue
Block a user