lua: add vim.in_fast_event() to check if we are in a luv callback

This commit is contained in:
Björn Linse
2019-08-04 21:56:29 +02:00
parent e6d77993d1
commit 88938634e7
3 changed files with 24 additions and 2 deletions

View File

@@ -223,6 +223,9 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
// schedule
lua_pushcfunction(lstate, &nlua_schedule);
lua_setfield(lstate, -2, "schedule");
// in_fast_event
lua_pushcfunction(lstate, &nlua_in_fast_event);
lua_setfield(lstate, -2, "in_fast_event");
// vim.loop
luv_set_loop(lstate, &main_loop.uv);
@@ -457,6 +460,12 @@ int nlua_debug(lua_State *lstate)
return 0;
}
int nlua_in_fast_event(lua_State *lstate)
{
lua_pushboolean(lstate, in_fast_callback > 0);
return 1;
}
#ifdef WIN32
/// os.getenv: override os.getenv to maintain coherency. #9681
///