From 9f0ecad6d97d3410aaf78f95fe13a0ff205ccdf4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 20 May 2026 11:52:22 -0400 Subject: fix(api): fail fast if `has_lua_imp` retval looks wrong #39866 --- src/nvim/lua/executor.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 1ab51d7386..4e017d23be 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1808,6 +1808,9 @@ static int mode_ret(LuaRetMode mode) Object nlua_call_ref_ctx(bool fast, LuaRef ref, const char *name, Array args, LuaRetMode mode, Arena *arena, Error *err) { + // Use active_lstate (set by ENTER_LUA_ACTIVE_STATE in gen_api_dispatch.lua) so callbacks run on + // the caller's Lua thread. This matters for coroutines: with global_lstate, return values pushed + // by kRetMultiStack would land on the main thread's stack, instead of coroutine stack. lua_State *const lstate = active_lstate; int top = lua_gettop(lstate); nlua_pushref(lstate, ref); -- cgit