]> granicus.if.org Git - vim/commitdiff
patch 8.2.4980: when 'shortmess' contains 'A' loading session may still warn v8.2.4980
authorBram Moolenaar <Bram@vim.org>
Wed, 18 May 2022 21:07:47 +0000 (22:07 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 18 May 2022 21:07:47 +0000 (22:07 +0100)
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)

src/session.c
src/testdir/test_mksession.vim
src/version.c

index bc259986ba0a33b4facc17c5e41d501b225049aa..fb9d1404ad24c3a070580044a6bc47c3a153ccf9 100644 (file)
@@ -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).
index ab224c4e8d6b2af42fd0a4175f6a3c07b29f8d71..2e368df8d9cbe3db28432938b62f67d5f7f86ee3 100644 (file)
@@ -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
index 37e3d80f869eb896a6ba00bf024025e76e26b10c..90d9618b9c46ae28c2a6a8b9460af003f47a7eb4 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4980,
 /**/
     4979,
 /**/