aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_session.c3
-rw-r--r--src/nvim/testdir/test_mksession.vim14
2 files changed, 16 insertions, 1 deletions
diff --git a/src/nvim/ex_session.c b/src/nvim/ex_session.c
index 4915070e91..63789b3981 100644
--- a/src/nvim/ex_session.c
+++ b/src/nvim/ex_session.c
@@ -388,7 +388,8 @@ static int put_view(
buf_T *const alt = buflist_findnr(wp->w_alt_fnum);
// Set the alternate file.
- if (alt != NULL && alt->b_fname != NULL && *alt->b_fname != NUL
+ if ((flagp == &ssop_flags) && alt != NULL && alt->b_fname != NULL
+ && *alt->b_fname != NUL
&& (fputs("balt ", fd) < 0
|| ses_fname(fd, alt, flagp, true) == FAIL)) {
return FAIL;
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index ca19885e3a..7c7804212b 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -317,6 +317,20 @@ func Test_mkview_open_folds()
%bwipe
endfunc
+func Test_mkview_no_balt()
+ edit Xtestfile1
+ edit Xtestfile2
+
+ mkview! Xtestview
+ bdelete Xtestfile1
+
+ 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.