From d9dd360d2aff7d3e1580367692c83fcd3647a439 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 7 Dec 2020 18:35:03 +0000 Subject: vim-patch:8.2.1967: the session file does not restore the alternate file Problem: The session file does not restore the alternate file. Solution: Add ":balt". Works like ":badd" and also sets the buffer as the alternate file. Use it in the session file. (closes vim/vim#7269, closes vim/vim#6714) https://github.com/vim/vim/commit/59d8e56e048eb5d384649284fb35363931fc3697 Include minimal test_buffer.vim from patch 8.2.0243 for Test_balt(). Add entry for :balt to runtime/doc/index.txt from vim/vim#7819. --- src/nvim/testdir/test_buffer.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/nvim/testdir/test_buffer.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_buffer.vim b/src/nvim/testdir/test_buffer.vim new file mode 100644 index 0000000000..f455b6911f --- /dev/null +++ b/src/nvim/testdir/test_buffer.vim @@ -0,0 +1,10 @@ +" Tests for Vim buffer + +func Test_balt() + new SomeNewBuffer + balt +3 OtherBuffer + e # + call assert_equal('OtherBuffer', bufname()) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From add0cf9a42a5122d74d0b89301802ba10bef802b Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 7 Dec 2020 20:10:58 +0000 Subject: vim-patch:8.2.2058: using mkview/loadview changes the jumplist Problem: Using mkview/loadview changes the jumplist. Solution: Use ":keepjumps". Don't let ":badd" or ":balt" change the jumplist. (closes vim/vim#7371) https://github.com/vim/vim/commit/3482be6a33c3a00fe1e8e604310ad3034f593045 Definition for BufWinEnter autocmd in Test_mkview_loadview_jumplist() was moved down a few lines until after the views are written, as in Nvim, :loadview throws if the view file can't be opened. --- src/nvim/testdir/test_mksession.vim | 75 +++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 88320e0c22..ca19885e3a 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -399,6 +399,58 @@ func Test_mkview_no_file_name() %bwipe endfunc +func Test_mkview_loadview_jumplist() + set viewdir=Xviewdir + au BufWinLeave * silent mkview + " au BufWinEnter * silent loadview + + edit Xfile1 + call setline(1, ['a', 'bbbbbbb', 'c']) + normal j3l + call assert_equal([2, 4], getcurpos()[1:2]) + write + + edit Xfile2 + call setline(1, ['d', 'eeeeeee', 'f']) + normal j5l + call assert_equal([2, 6], getcurpos()[1:2]) + write + + edit Xfile3 + call setline(1, ['g', 'h', 'iiiii']) + normal jj3l + call assert_equal([3, 4], getcurpos()[1:2]) + write + + " The commented :au above was moved here so that :mkview (on BufWinLeave) can + " run before :loadview. This is needed because Nvim's :loadview raises E484 if + " the view can't be opened, while Vim's silently fails instead. + au BufWinEnter * silent loadview + + edit Xfile1 + call assert_equal([2, 4], getcurpos()[1:2]) + edit Xfile2 + call assert_equal([2, 6], getcurpos()[1:2]) + edit Xfile3 + call assert_equal([3, 4], getcurpos()[1:2]) + + exe "normal \" + call assert_equal('Xfile2', expand('%')) + call assert_equal([2, 6], getcurpos()[1:2]) + exe "normal \" + call assert_equal('Xfile1', expand('%')) + call assert_equal([2, 4], getcurpos()[1:2]) + + au! BufWinLeave + au! BufWinEnter + bwipe! + call delete('Xviewdir', 'rf') + call delete('Xfile1') + call delete('Xfile2') + call delete('Xfile3') + set viewdir& +endfunc + " A clean session (one empty buffer, one window, and one tab) should not " set any error messages when sourced because no commands should fail. func Test_mksession_no_errmsg() @@ -689,4 +741,27 @@ func Test_scrolloff() set sessionoptions& endfunc +func Test_altfile() + edit Xone + split Xtwo + edit Xtwoalt + edit # + wincmd w + edit Xonealt + edit # + mksession! Xtest_altfile + only + bwipe Xonealt + bwipe Xtwoalt + bwipe! + source Xtest_altfile + call assert_equal('Xone', bufname()) + call assert_equal('Xonealt', bufname('#')) + wincmd w + call assert_equal('Xtwo', bufname()) + call assert_equal('Xtwoalt', bufname('#')) + only + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 4bc82a59b6fc3927ce20c7cadb080ed1c9d6fce8 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 11 Feb 2021 03:42:15 +0000 Subject: vim-patch:8.2.2467: script generated by :mkview changes alternate file Problem: Script generated by :mkview changes alternate file. Solution: Only write :balt in the session file. (Harish Rajagopal, closes vim/vim#7779) https://github.com/vim/vim/commit/139348f3e8370826a1ceb10c73f7c7bb586f8125 --- src/nvim/testdir/test_mksession.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/nvim/testdir') 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. -- cgit