aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-09 12:47:40 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-03-09 13:38:32 +0800
commit33dfb5a383d7afacda35b8fd392ad18d57db2870 (patch)
tree860dfa50f29daa54a5726abce8c32f2d697cda12 /test/functional/ui/float_spec.lua
parent6416c6bc94fa7ae553a6020d0ed2f07dd34ee3f1 (diff)
downloadrneovim-33dfb5a383d7afacda35b8fd392ad18d57db2870.tar.gz
rneovim-33dfb5a383d7afacda35b8fd392ad18d57db2870.tar.bz2
rneovim-33dfb5a383d7afacda35b8fd392ad18d57db2870.zip
fix(window): :close may cause Nvim to quit with autocmd and float
Problem: :close may cause Nvim to quit if an autocommand triggered when closing the buffer closes all other non-floating windows and there are floating windows. Solution: Correct the check for the only non-floating window.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index e324d03b30..8b7107fdf2 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -873,6 +873,39 @@ describe('float window', function()
end)
end)
+ describe(':close on non-float with floating windows', function()
+ it('does not quit Nvim if BufWinLeave makes it the only non-float', function()
+ exec([[
+ let firstbuf = bufnr()
+ new
+ let midwin = win_getid()
+ new
+ setlocal bufhidden=wipe
+ call nvim_win_set_config(midwin,
+ \ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
+ autocmd BufWinLeave * ++once exe firstbuf .. 'bwipe!'
+ ]])
+ eq('Vim(close):E855: Autocommands caused command to abort', pcall_err(command, 'close'))
+ assert_alive()
+ end)
+
+ pending('does not crash if BufWinLeave makes it the only non-float in tabpage', function()
+ exec([[
+ tabnew
+ let firstbuf = bufnr()
+ new
+ let midwin = win_getid()
+ new
+ setlocal bufhidden=wipe
+ call nvim_win_set_config(midwin,
+ \ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
+ autocmd BufWinLeave * ++once exe firstbuf .. 'bwipe!'
+ ]])
+ eq('Vim(close):E855: Autocommands caused command to abort', pcall_err(command, 'close'))
+ assert_alive()
+ end)
+ end)
+
local function with_ext_multigrid(multigrid)
local screen, attrs
before_each(function()