summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-18 22:07:47 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-18 22:07:47 +0100
commitaaadb5b6f76ea03e5eb460121f3dbf46ad04ce50 (patch)
tree84cf3b2e1c3686f155acc7d3d613942ab3f3876b
parent28d032cc688ccfda18c5bbcab8b50aba6e18cde5 (diff)
downloadvim-git-aaadb5b6f76ea03e5eb460121f3dbf46ad04ce50.tar.gz
patch 8.2.4980: when 'shortmess' contains 'A' loading session may still warnv8.2.4980
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 #10443)
-rw-r--r--src/session.c9
-rw-r--r--src/testdir/test_mksession.vim22
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 2 deletions
diff --git a/src/session.c b/src/session.c
index bc259986b..fb9d1404a 100644
--- a/src/session.c
+++ b/src/session.c
@@ -692,10 +692,15 @@ makeopens(
&& 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)
+ // set 'shortmess' for the following. Add the 'A' flag if it was there
+ if (put_line(fd, "if &shortmess =~ 'A'") == FAIL
+ || put_line(fd, " set shortmess=aoOA") == FAIL
+ || put_line(fd, "else") == FAIL
+ || put_line(fd, " set shortmess=aoO") == FAIL
+ || put_line(fd, "endif") == FAIL)
goto fail;
+ // 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).
diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim
index ab224c4e8..2e368df8d 100644
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -1078,6 +1078,28 @@ 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('%')
+ let cont = readblob(fname)
+ 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()
mksession! Xtest_mks1.out
diff --git a/src/version.c b/src/version.c
index 37e3d80f8..90d9618b9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4980,
+/**/
4979,
/**/
4978,