summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Cherti <60946298+jamescherti@users.noreply.github.com>2022-03-29 12:02:57 +0100
committerBram Moolenaar <Bram@vim.org>2022-03-29 12:02:57 +0100
commitfd01280d01c2270a320d8c962d24140a8176a400 (patch)
tree9b88b32b871a57862c91c4461ee8531fd47f57a2
parent1624639ec8a6c3c99e417a2990f2f02f0d0b6e10 (diff)
patch 8.2.4645: 'shortmess' changed when session does not store optionsv8.2.4645
Problem: 'shortmess' changed when session does not store options. Solution: Save and restore 'shortmess' if needed. (James Charti, closes #10037)
-rw-r--r--src/session.c24
-rw-r--r--src/testdir/test_mksession.vim43
-rw-r--r--src/version.c2
3 files changed, 66 insertions, 3 deletions
diff --git a/src/session.c b/src/session.c
index fa77f89c8e..d80f11ff7c 100644
--- a/src/session.c
+++ b/src/session.c
@@ -686,6 +686,11 @@ makeopens(
if (put_line(fd, "endif") == FAIL)
goto fail;
+ // save 'shortmess' if not storing options
+ if ((ssop_flags & SSOP_OPTIONS) == 0
+ && put_line(fd, "let s:shortmess_save = &shortmess") == FAIL)
+ goto fail;
+
// Now save the current files, current buffer first.
if (put_line(fd, "set shortmess=aoO") == FAIL)
goto fail;
@@ -956,10 +961,23 @@ makeopens(
if (put_line(fd, "unlet! s:wipebuf") == FAIL)
goto fail;
- // Re-apply 'winheight', 'winwidth' and 'shortmess'.
- if (fprintf(fd, "set winheight=%ld winwidth=%ld shortmess=%s",
- p_wh, p_wiw, p_shm) < 0 || put_eol(fd) == FAIL)
+ // Re-apply 'winheight' and 'winwidth'.
+ if (fprintf(fd, "set winheight=%ld winwidth=%ld",
+ p_wh, p_wiw) < 0 || put_eol(fd) == FAIL)
goto fail;
+
+ // Restore 'shortmess'.
+ if (ssop_flags & SSOP_OPTIONS)
+ {
+ if (fprintf(fd, "set shortmess=%s", p_shm) < 0 || put_eol(fd) == FAIL)
+ goto fail;
+ }
+ else
+ {
+ if (put_line(fd, "let &shortmess = s:shortmess_save") == FAIL)
+ goto fail;
+ }
+
if (tab_firstwin->w_next != NULL)
{
// Restore 'winminheight' and 'winminwidth'.
diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim
index 2c2737e006..247d1797d1 100644
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -1007,6 +1007,49 @@ func Test_mksession_winminheight()
set sessionoptions&
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
func Test_mksession_compatible()
mksession! Xtest_mks1.out
diff --git a/src/version.c b/src/version.c
index 90b30ab321..03778bd5ca 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4645,
+/**/
4644,
/**/
4643,