From 84bbe4b0ca935db1f6202db339aee5594a3b3908 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 21 Nov 2023 11:24:30 +0000 Subject: fix(lua): disallow vim.wait() in fast contexts `vim.wait()` cannot be called in a fast callback since the main loop cannot be run in that context as it is not reentrant Fixes #26122 --- test/functional/lua/vim_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/functional/lua/vim_spec.lua') diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 1533a1823f..61fa16f59d 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2769,6 +2769,19 @@ describe('lua stdlib', function() eq({'notification', 'wait', {-2}}, next_msg(500)) end) end) + + it('should not run in fast callbacks #26122', function() + exec_lua([[ + vim.uv.new_timer():start(0, 100, function() + local count = 0 + vim.wait(100, function() + count = count + 1 + return count == 10 + end, 100) + end) + ]]) + assert_alive() + end) end) it('vim.notify_once', function() -- cgit