diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-11-21 11:24:30 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2023-11-27 09:09:21 +0000 |
commit | 84bbe4b0ca935db1f6202db339aee5594a3b3908 (patch) | |
tree | f71a1a2d3ab75f1b1deece31065e80c46b1b842e /test/functional/lua/vim_spec.lua | |
parent | 6343d414369de1f3b259e51438cd4f666d82d3d2 (diff) | |
download | rneovim-84bbe4b0ca935db1f6202db339aee5594a3b3908.tar.gz rneovim-84bbe4b0ca935db1f6202db339aee5594a3b3908.tar.bz2 rneovim-84bbe4b0ca935db1f6202db339aee5594a3b3908.zip |
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
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 13 |
1 files changed, 13 insertions, 0 deletions
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() |