From b87bdef2a8649ce40a8f722432934bef3d6d4b57 Mon Sep 17 00:00:00 2001 From: skewb1k Date: Wed, 10 Dec 2025 17:44:05 +0300 Subject: 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. --- src/nvim/lua/executor.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/nvim/lua/executor.c') 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); -- cgit