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.
This commit is contained in:
Barrett Ruth
2026-04-22 13:36:43 -04:00
committed by GitHub
parent 496374e951
commit fb6aeaba2d
3 changed files with 27 additions and 4 deletions

View File

@@ -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);