vim-patch:9.1.0158: 'shortmess' "F" flag doesn't work properly with 'autoread'

Problem:  'shortmess' "F" flag doesn't work properly with 'autoread'
          (after 9.1.0154)
Solution: Hide the file info message instead of the warning dialog
          (zeertzjq)

closes: vim/vim#14159
closes: vim/vim#14158

8a01744c56
This commit is contained in:
zeertzjq
2024-03-08 06:53:43 +08:00
parent d741e5d162
commit c38764182a
3 changed files with 29 additions and 11 deletions

View File

@@ -3008,7 +3008,7 @@ int buf_check_timestamp(buf_T *buf)
can_reload = true; can_reload = true;
} }
if (mesg != NULL && !shortmess(SHM_FILEINFO)) { if (mesg != NULL) {
char *path = home_replace_save(buf, buf->b_fname); char *path = home_replace_save(buf, buf->b_fname);
if (!helpmesg) { if (!helpmesg) {
mesg2 = ""; mesg2 = "";
@@ -3153,7 +3153,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, 0, 0, if (readfile(buf->b_ffname, buf->b_fname, 0, 0,
(linenr_T)MAXLNUM, &ea, flags, false) != OK) { (linenr_T)MAXLNUM, &ea, flags, shortmess(SHM_FILEINFO)) != OK) {
if (!aborting()) { if (!aborting()) {
semsg(_("E321: Could not reload \"%s\""), buf->b_fname); semsg(_("E321: Could not reload \"%s\""), buf->b_fname);
} }

View File

@@ -86,7 +86,7 @@ describe('autoread TUI FocusGained/FocusLost', function()
line 3 | line 3 |
line 4 | line 4 |
{5:xtest-foo }| {5:xtest-foo }|
"xtest-foo" 4L, 28B | :edit xtest-foo |
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]], ]],
} }

View File

@@ -1284,23 +1284,41 @@ func Test_shortmess_F2()
endfunc endfunc
func Test_shortmess_F3() func Test_shortmess_F3()
defer delete('X_dummy') call writefile(['foo'], 'X_dummy', 'D')
set hidden set hidden
set autoread set autoread
e X_dummy e X_dummy
e file e Xotherfile
call assert_equal(['foo'], getbufline('X_dummy', 1, '$'))
set shortmess+=F set shortmess+=F
call writefile(["foo"], 'X_dummy') echo ''
call assert_true(empty(execute('bn', '')))
call assert_true(empty(execute('bn', ''))) if has('nanotime')
sleep 10m
else
sleep 2
endif
call writefile(['bar'], 'X_dummy')
bprev
call assert_equal('', Screenline(&lines))
call assert_equal(['bar'], getbufline('X_dummy', 1, '$'))
if has('nanotime')
sleep 10m
else
sleep 2
endif
call writefile(['baz'], 'X_dummy')
checktime
call assert_equal('', Screenline(&lines))
call assert_equal(['baz'], getbufline('X_dummy', 1, '$'))
set shortmess& set shortmess&
set autoread& set autoread&
set hidden& set hidden&
bwipe bwipe X_dummy
bwipe bwipe Xotherfile
endfunc endfunc
func Test_local_scrolloff() func Test_local_scrolloff()