# HG changeset patch # User Bram Moolenaar # Date 1615640404 -3600 # Node ID 3b5d499c2bb5c5c92753a7e20c59ec3d52e69527 # Parent bf6279dbaff73c9f71886c91f54176fdfcefbfb8 patch 8.2.2594: alternate buffer added to session file even when it's hidden Commit: https://github.com/vim/vim/commit/0756f757edba755b75e0c9c612ab2f7e673def84 Author: Bram Moolenaar Date: Sat Mar 13 13:52:33 2021 +0100 patch 8.2.2594: alternate buffer added to session file even when it's hidden Problem: Alternate buffer added to session file even when it's hidden. Solution: Check the 'buflisted' option. (closes https://github.com/vim/vim/issues/7951) diff --git a/src/session.c b/src/session.c --- a/src/session.c +++ b/src/session.c @@ -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; diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim --- a/src/testdir/test_mksession.vim +++ b/src/testdir/test_mksession.vim @@ -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. diff --git a/src/version.c b/src/version.c --- 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 */ /**/ + 2594, +/**/ 2593, /**/ 2592,