diff options
| author | skewb1k <skewb1kunix@gmail.com> | 2025-12-10 17:44:05 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-12-10 09:44:05 -0500 |
| commit | b87bdef2a8649ce40a8f722432934bef3d6d4b57 (patch) | |
| tree | e4fae0ad92e153918645bb9e1e15bfdb45b10d31 /src/nvim/lua/executor.c | |
| parent | d2e445e1bd321ea43b976d6aa7759d90b826ce62 (diff) | |
| download | rneovim-b87bdef2a8649ce40a8f722432934bef3d6d4b57.tar.gz rneovim-b87bdef2a8649ce40a8f722432934bef3d6d4b57.tar.bz2 rneovim-b87bdef2a8649ce40a8f722432934bef3d6d4b57.zip | |
fix(lua): relax `vim.wait()` timeout validation #36900
Problem:
After bc0635a9fc9c15a2423d4eb35f627d127d00fa46 `vim.wait()` rejects floats
and NaN values.
Solution:
Restore the prior behavior, while still supporting `math.huge`. Update
tests to cover float case.
Diffstat (limited to 'src/nvim/lua/executor.c')
| -rw-r--r-- | src/nvim/lua/executor.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 30d3f26f0e..4073e0f9a8 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -456,15 +456,9 @@ static int nlua_wait(lua_State *lstate) if (timeout_number < 0) { return luaL_error(lstate, "timeout must be >= 0"); } - int64_t timeout; - if (isinf(timeout_number) || timeout_number > (double)INT64_MAX) { - timeout = INT64_MAX; - } else { - if (isnan(timeout_number) || timeout_number != trunc(timeout_number)) { - return luaL_error(lstate, "timeout has no integer representation"); - } - timeout = (int64_t)timeout_number; - } + int64_t timeout = (isnan(timeout_number) || timeout_number > (double)INT64_MAX) + ? INT64_MAX + : (int64_t)timeout_number; int lua_top = lua_gettop(lstate); |