mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
vim-patch:8.2.4645: 'shortmess' changed when session does not store options (#17908)
Problem: 'shortmess' changed when session does not store options.
Solution: Save and restore 'shortmess' if needed. (James Charti,
closes vim/vim#10037)
fd01280d01
This commit is contained in:
@@ -589,12 +589,18 @@ static int makeopens(FILE *fd, char_u *dirnow)
|
|||||||
"if expand('%') == '' && !&modified && line('$') <= 1"
|
"if expand('%') == '' && !&modified && line('$') <= 1"
|
||||||
" && getline(1) == ''\n"
|
" && getline(1) == ''\n"
|
||||||
" let s:wipebuf = bufnr('%')\n"
|
" let s:wipebuf = bufnr('%')\n"
|
||||||
"endif\n"
|
"endif\n") < 0) {
|
||||||
// Now save the current files, current buffer first.
|
|
||||||
"set shortmess=aoO\n") < 0) {
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save 'shortmess' if not storing options
|
||||||
|
if ((ssop_flags & SSOP_OPTIONS) == 0) {
|
||||||
|
PUTLINE_FAIL("let s:shortmess_save = &shortmess");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now save the current files, current buffer first.
|
||||||
|
PUTLINE_FAIL("set shortmess=aoO");
|
||||||
|
|
||||||
// Put all buffers into the buffer list.
|
// Put all buffers into the buffer list.
|
||||||
// Do it very early to preserve buffer order after loading session (which
|
// Do it very early to preserve buffer order after loading session (which
|
||||||
// can be disrupted by prior `edit` or `tabedit` calls).
|
// can be disrupted by prior `edit` or `tabedit` calls).
|
||||||
@@ -842,15 +848,21 @@ static int makeopens(FILE *fd, char_u *dirnow)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-apply 'winheight', 'winwidth' and 'shortmess'.
|
// Re-apply 'winheight' and 'winwidth'.
|
||||||
if (fprintf(fd,
|
if (fprintf(fd, "set winheight=%" PRId64 " winwidth=%" PRId64 "\n",
|
||||||
"set winheight=%" PRId64 " winwidth=%" PRId64
|
(int64_t)p_wh, (int64_t)p_wiw) < 0) {
|
||||||
" shortmess=%s\n",
|
|
||||||
(int64_t)p_wh,
|
|
||||||
(int64_t)p_wiw,
|
|
||||||
p_shm) < 0) {
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore 'shortmess'.
|
||||||
|
if (ssop_flags & SSOP_OPTIONS) {
|
||||||
|
if (fprintf(fd, "set shortmess=%s\n", p_shm) < 0) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PUTLINE_FAIL("let &shortmess = s:shortmess_save");
|
||||||
|
}
|
||||||
|
|
||||||
if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) {
|
if (tab_firstwin != NULL && tab_firstwin->w_next != NULL) {
|
||||||
// Restore 'winminheight' and 'winminwidth'.
|
// Restore 'winminheight' and 'winminwidth'.
|
||||||
PUTLINE_FAIL("let &winminheight = s:save_winminheight");
|
PUTLINE_FAIL("let &winminheight = s:save_winminheight");
|
||||||
|
|||||||
@@ -795,6 +795,49 @@ func Test_mksession_winminheight()
|
|||||||
set sessionoptions&
|
set sessionoptions&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for mksession with and without options restores shortmess
|
||||||
|
func Test_mksession_shortmess()
|
||||||
|
" Without options
|
||||||
|
set sessionoptions-=options
|
||||||
|
split
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
let found_save = 0
|
||||||
|
let found_restore = 0
|
||||||
|
let lines = readfile('Xtest_mks.out')
|
||||||
|
for line in lines
|
||||||
|
let line = trim(line)
|
||||||
|
|
||||||
|
if line ==# 'let s:shortmess_save = &shortmess'
|
||||||
|
let found_save += 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if found_save !=# 0 && line ==# 'let &shortmess = s:shortmess_save'
|
||||||
|
let found_restore += 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call assert_equal(1, found_save)
|
||||||
|
call assert_equal(1, found_restore)
|
||||||
|
call delete('Xtest_mks.out')
|
||||||
|
close
|
||||||
|
set sessionoptions&
|
||||||
|
|
||||||
|
" With options
|
||||||
|
set sessionoptions+=options
|
||||||
|
split
|
||||||
|
mksession! Xtest_mks.out
|
||||||
|
let found_restore = 0
|
||||||
|
let lines = readfile('Xtest_mks.out')
|
||||||
|
for line in lines
|
||||||
|
if line =~# 's:shortmess_save'
|
||||||
|
let found_restore += 1
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call assert_equal(0, found_restore)
|
||||||
|
call delete('Xtest_mks.out')
|
||||||
|
close
|
||||||
|
set sessionoptions&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for mksession with 'compatible' option
|
" Test for mksession with 'compatible' option
|
||||||
func Test_mksession_compatible()
|
func Test_mksession_compatible()
|
||||||
throw 'skipped: Nvim does not support "compatible" option'
|
throw 'skipped: Nvim does not support "compatible" option'
|
||||||
|
|||||||
Reference in New Issue
Block a user