mirror of
https://github.com/neovim/neovim.git
synced 2026-08-26 17:11:48 +00:00
fix(lua): relax vim.wait() timeout validation #36900
Problem:
After bc0635a9fc `vim.wait()` rejects floats
and NaN values.
Solution:
Restore the prior behavior, while still supporting `math.huge`. Update
tests to cover float case.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user