From fb6aeaba2d3a38c7febd0a39cabd89685de11b9d Mon Sep 17 00:00:00 2001 From: Barrett Ruth <62671086+barrettruth@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:36:43 -0400 Subject: feat(eval): treat Lua string as "blob" in writefile() #39098 Problem: vim.fn.writefile() treats Lua strings as Vimscript strings instead of a "binary clean" string. Solution: Treat Lua-originated strings as blob data. --- src/nvim/lua/executor.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 1771a01565..02a95d5f6d 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1366,12 +1366,14 @@ int nlua_call(lua_State *lstate) funcexe.fe_firstline = curwin->w_cursor.lnum; funcexe.fe_lastline = curwin->w_cursor.lnum; funcexe.fe_evaluate = true; + const sctx_T save_current_sctx = api_set_sctx(LUA_INTERNAL_CALL); TRY_WRAP(&err, { // call_func() retval is deceptive, ignore it. Instead we set `msg_list` // (TRY_WRAP) to capture abort-causing non-exception errors. (void)call_func(name, (int)name_len, &rettv, nargs, vim_args, &funcexe); }); + current_sctx = save_current_sctx; if (!ERROR_SET(&err)) { nlua_push_typval(lstate, &rettv, 0); -- cgit