vim-patch:9.1.2136: :tab sbuffer may close old tabpage (#37765)

Problem:  :tab sbuffer may close old tabpage if BufLeave autocommand
          splits window (after 9.1.0143).
Solution: Only close other windows if the buffer will be unloaded
          (zeertzjq).

related: neovim/neovim#37749
closes: vim/vim#19352

6da9f757c4
This commit is contained in:
zeertzjq
2026-02-07 23:03:21 +08:00
committed by GitHub
parent 1196bf8f40
commit e704529909
3 changed files with 37 additions and 3 deletions

View File

@@ -882,4 +882,37 @@ func Test_bdelete_skip_closing_bufs()
%bw!
endfunc
func Test_split_window_in_BufLeave_from_tab_sbuffer()
tabnew Xa
setlocal bufhidden=wipe
let t0 = tabpagenr()
let b0 = bufnr()
let b1 = bufadd('Xb')
autocmd BufLeave Xa ++once split
exe 'tab sbuffer' b1
call assert_equal(t0 + 1, tabpagenr())
call assert_equal([b1, b0], tabpagebuflist())
call assert_equal([b0], tabpagebuflist(t0))
tabclose
call assert_equal(t0, tabpagenr())
call assert_equal([b0], tabpagebuflist())
bwipe! Xa
bwipe! Xb
endfunc
func Test_split_window_in_BufLeave_from_switching_buffer()
tabnew Xa
setlocal bufhidden=wipe
split
let b0 = bufnr()
let b1 = bufadd('Xb')
autocmd BufLeave Xa ++once split
exe 'buffer' b1
call assert_equal([b1, b0, b0], tabpagebuflist())
bwipe! Xa
bwipe! Xb
endfunc
" vim: shiftwidth=2 sts=2 expandtab