vim-patch:8.2.4980: when 'shortmess' contains 'A' loading session may still warn (#18636)

Problem:    When 'shortmess' contains 'A' loading a session may still warn for
            an existing swap file. (Melker Österberg)
Solution:   Keep the 'A' flag to 'shortmess' in the session file.
            (closes vim/vim#10443)
aaadb5b6f7

Use readfile() with "B" flag in test as readblob() needs patch 8.2.2343.
This commit is contained in:
zeertzjq 2022-05-20 07:20:38 +08:00 committed by GitHub
parent 69853a622a
commit eb0aa8bb0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -598,9 +598,14 @@ static int makeopens(FILE *fd, char_u *dirnow)
PUTLINE_FAIL("let s:shortmess_save = &shortmess");
}
// Now save the current files, current buffer first.
PUTLINE_FAIL("set shortmess=aoO");
// set 'shortmess' for the following. Add the 'A' flag if it was there
PUTLINE_FAIL("if &shortmess =~ 'A'");
PUTLINE_FAIL(" set shortmess=aoOA");
PUTLINE_FAIL("else");
PUTLINE_FAIL(" set shortmess=aoO");
PUTLINE_FAIL("endif");
// Now save the current files, current buffer first.
// Put all buffers into the buffer list.
// Do it very early to preserve buffer order after loading session (which
// can be disrupted by prior `edit` or `tabedit` calls).

View File

@ -838,6 +838,30 @@ func Test_mksession_shortmess()
set sessionoptions&
endfunc
" Test that when Vim loading session has 'A' in 'shortmess' it does not
" complain about an existing swapfile.
func Test_mksession_shortmess_with_A()
edit Xtestfile
write
let fname = swapname('%')
" readblob() needs patch 8.2.2343
" let cont = readblob(fname)
let cont = readfile(fname, 'B')
set sessionoptions-=options
mksession Xtestsession
bwipe!
" Recreate the swap file to pretend the file is being edited
call writefile(cont, fname)
set shortmess+=A
source Xtestsession
set shortmess&
set sessionoptions&
call delete('Xtestsession')
call delete(fname)
endfunc
" Test for mksession with 'compatible' option
func Test_mksession_compatible()
throw 'skipped: Nvim does not support "compatible" option'