mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
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
31be82e66d
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
This commit is contained in:
@@ -4507,4 +4507,31 @@ func Test_reuse_curbuf_leak()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user