]> granicus.if.org Git - vim/commitdiff
patch 8.2.2594: alternate buffer added to session file even when it's hidden v8.2.2594
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Mar 2021 12:52:33 +0000 (13:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Mar 2021 12:52:33 +0000 (13:52 +0100)
Problem:    Alternate buffer added to session file even when it's hidden.
Solution:   Check the 'buflisted' option. (closes #7951)

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

index a734656d54d7d955093d96e24d438c9f28cdb448..6e73bb67661e5e3204a3c8528363abdf38221786 100644 (file)
@@ -401,11 +401,12 @@ put_view(
     {
        buf_T *alt = buflist_findnr(wp->w_alt_fnum);
 
-       // Set the alternate file.
+       // Set the alternate file if the buffer is listed.
        if ((flagp == &ssop_flags)
                && alt != NULL
                && alt->b_fname != NULL
                && *alt->b_fname != NUL
+               && alt->b_p_bl
                && (fputs("balt ", fd) < 0
                || ses_fname(fd, alt, flagp, TRUE) == FAIL))
            return FAIL;
index eb8c6a5a46113f9ab18c2824ae2a7f89a6957721..6e365537332e89b6bb145ba27264db12ab5cc174 100644 (file)
@@ -544,6 +544,20 @@ func Test_mkview_no_balt()
   %bwipe
 endfunc
 
+func Test_mksession_no_balt()
+  edit Xtestfile1
+  edit Xtestfile2
+
+  bdelete Xtestfile1
+  mksession! Xtestview
+
+  source Xtestview
+  call assert_equal(0, buflisted('Xtestfile1'))
+
+  call delete('Xtestview')
+  %bwipe
+endfunc
+
 " Test :mkview with a file argument.
 func Test_mkview_file()
   " Create a view with line number and a fold.
index 45973eac26041e533ca5c6d8e370bc4b50af7ede..f1b823226e07b68a2ba0292b11b0506d15fc4e27 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2594,
 /**/
     2593,
 /**/