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 /src/nvim/lua/executor.c | |
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 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index ce2a247a6f..04eda99d17 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -411,6 +411,10 @@ static bool nlua_wait_condition(lua_State *lstate, int *status, bool *callback_r static int nlua_wait(lua_State *lstate) FUNC_ATTR_NONNULL_ALL { + if (in_fast_callback) { + return luaL_error(lstate, e_luv_api_disabled, "vim.wait"); + } + intptr_t timeout = luaL_checkinteger(lstate, 1); if (timeout < 0) { return luaL_error(lstate, "timeout must be >= 0"); @@ -449,8 +453,7 @@ static int nlua_wait(lua_State *lstate) fast_only = lua_toboolean(lstate, 4); } - MultiQueue *loop_events = fast_only || in_fast_callback > 0 - ? main_loop.fast_events : main_loop.events; + MultiQueue *loop_events = fast_only ? main_loop.fast_events : main_loop.events; TimeWatcher *tw = xmalloc(sizeof(TimeWatcher)); |