commit 038eb01b41b66379f75164507571497929f8847c
parent 53ac2ad20ab26b147d64da48a5e3684c2541c844
Author: zeertzjq <zeertzjq@outlook.com>
Date: Fri, 8 Aug 2025 07:42:34 +0800
Merge pull request #35225 from zeertzjq/vim-8.1.0425
vim-patch:{8.1.0425,9.1.1601}
Diffstat:
2 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/test/old/testdir/test_buffer.vim b/test/old/testdir/test_buffer.vim
@@ -609,4 +609,31 @@ func Test_closed_buffer_still_in_window()
%bw!
endfunc
+" Cursor position should be restored when switching to a buffer previously
+" viewed in a window, regardless of whether it's visible in another one.
+func Test_switch_to_previously_viewed_buffer()
+ set nostartofline
+ new Xviewbuf
+ call setline(1, range(1, 200))
+ let oldwin = win_getid()
+ vsplit
+
+ call cursor(100, 3)
+ edit Xotherbuf
+ buffer Xviewbuf
+ call assert_equal([0, 100, 3, 0], getpos('.'))
+
+ exe win_id2win(oldwin) .. 'close'
+ setlocal bufhidden=hide
+
+ call cursor(200, 3)
+ edit Xotherbuf
+ buffer Xviewbuf
+ call assert_equal([0, 200, 3, 0], getpos('.'))
+
+ bwipe! Xotherbuf
+ bwipe! Xviewbuf
+ set startofline&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_bufline.vim b/test/old/testdir/test_bufline.vim
@@ -158,6 +158,33 @@ func Test_appendbufline()
exe "bwipe! " . b
endfunc
+func Test_appendbufline_no_E315()
+ let after = [
+ \ 'set stl=%f ls=2',
+ \ 'new',
+ \ 'let buf = bufnr("%")',
+ \ 'quit',
+ \ 'vsp',
+ \ 'exec "buffer" buf',
+ \ 'wincmd w',
+ \ 'call appendbufline(buf, 0, "abc")',
+ \ 'redraw',
+ \ 'while getbufline(buf, 1)[0] =~ "^\\s*$"',
+ \ ' sleep 10m',
+ \ 'endwhile',
+ \ 'au VimLeavePre * call writefile([v:errmsg], "Xerror")',
+ \ 'au VimLeavePre * call writefile(["done"], "Xdone")',
+ \ 'qall!',
+ \ ]
+ if !RunVim([], after, '--clean')
+ return
+ endif
+ call assert_notmatch("^E315:", readfile("Xerror")[0])
+ call assert_equal("done", readfile("Xdone")[0])
+ call delete("Xerror")
+ call delete("Xdone")
+endfunc
+
func Test_deletebufline()
new
let b = bufnr('%')