neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 2fda267faf0ba6e5ac63654f66f83d6589238b8f
parent 70eb4164591e9efb291759f698c09c7a1b211c93
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date:   Thu, 15 May 2025 20:22:15 +0100

vim-patch:9.1.1393: missing test for switching buffers and reusing curbuf

Problem:  The check in buf_freeall that restores curwin subtly prevents
          leaving an unloaded buffer in a window when reusing curbuf, if
          autocommands switch to a different buffer.
Solution: Add a test case that covers this. Also ensure splitting isn't
          possible, as that could do the same (Sean Dewar)

closes: vim/vim#17325

https://github.com/vim/vim/commit/31be82e66d412000f1d964a36bb8a03d40eaaeac

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>

Diffstat:
Mtest/old/testdir/test_autocmd.vim | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim @@ -4507,4 +4507,31 @@ func Test_reuse_curbuf_leak() %bw! endfunc +func Test_reuse_curbuf_switch() + edit asdf + let s:asdf_win = win_getid() + new + let other_buf = bufnr() + let other_win = win_getid() + augroup testing + autocmd! + autocmd BufUnload * ++once let s:triggered = 1 + \| call assert_fails('split', 'E1159:') + \| call win_gotoid(s:asdf_win) + augroup END + + " Check BufUnload changing curbuf does not cause buflist_new to create a new + " buffer while leaving "other_buf" unloaded in a window. + enew + call assert_equal(1, s:triggered) + call assert_equal(other_buf, bufnr()) + call assert_equal(other_win, win_getid()) + call assert_equal(1, win_findbuf(other_buf)->len()) + call assert_equal(1, bufloaded(other_buf)) + + unlet! s:asdf_win s:triggered + call CleanUpTestAuGroup() + %bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab