aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/float_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-27 17:29:05 +0800
committerGitHub <noreply@github.com>2022-12-27 17:29:05 +0800
commitcd6ec1db068f9f4c1900a00b5392e39e59f0a7cb (patch)
tree62a308bd578bfbe0cc2374366770b6722632486b /test/functional/ui/float_spec.lua
parentd4af8c6202e8734ef4a3a3dfe249353f8d5ba551 (diff)
downloadrneovim-cd6ec1db068f9f4c1900a00b5392e39e59f0a7cb.tar.gz
rneovim-cd6ec1db068f9f4c1900a00b5392e39e59f0a7cb.tar.bz2
rneovim-cd6ec1db068f9f4c1900a00b5392e39e59f0a7cb.zip
fix(win_close): remove float grid after closing buffer (#21551)
It is not safe to remove the float grid when autocommands can still be triggered, as autocommands may use the float grid.
Diffstat (limited to 'test/functional/ui/float_spec.lua')
-rw-r--r--test/functional/ui/float_spec.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index bb09cfd504..ab87384194 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -8831,6 +8831,34 @@ describe('float window', function()
]]}
end
end)
+
+ describe('no crash after moving and closing float window #21547', function()
+ local function test_float_move_close(cmd)
+ local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
+ meths.open_win(meths.create_buf(false, false), true, float_opts)
+ if multigrid then
+ screen:expect({float_pos = {[4] = {{id = 1001}, 'NW', 1, 1, 1, true}}})
+ end
+ command(cmd)
+ exec_lua([[
+ vim.api.nvim_win_set_config(0, {relative = 'editor', row = 2, col = 2})
+ vim.api.nvim_win_close(0, {})
+ vim.api.nvim_echo({{''}}, false, {})
+ ]])
+ if multigrid then
+ screen:expect({float_pos = {}})
+ end
+ assert_alive()
+ end
+
+ it('if WinClosed autocommand flushes UI', function()
+ test_float_move_close('autocmd WinClosed * ++once redraw')
+ end)
+
+ it('if closing buffer flushes UI', function()
+ test_float_move_close('autocmd BufWinLeave * ++once redraw')
+ end)
+ end)
end
describe('with ext_multigrid', function()