aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-05-20 11:52:22 -0400
committerGitHub <noreply@github.com>2026-05-20 11:52:22 -0400
commit9f0ecad6d97d3410aaf78f95fe13a0ff205ccdf4 (patch)
tree538da653fffd3b96abe6710105e00d9f1ff0bc9e /src/nvim/lua/executor.c
parent584dfdb76d1c2fdd249ff1e817cf09001b365814 (diff)
downloadrneovim-9f0ecad6d97d3410aaf78f95fe13a0ff205ccdf4.tar.gz
rneovim-9f0ecad6d97d3410aaf78f95fe13a0ff205ccdf4.tar.bz2
rneovim-9f0ecad6d97d3410aaf78f95fe13a0ff205ccdf4.zip
fix(api): fail fast if `has_lua_imp` retval looks wrong #39866
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c3
1 files changed, 3 insertions, 0 deletions
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);