aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2026-10-03 13:20:33 +0200
committerbfredl <bjorn.linse@gmail.com>2026-10-06 11:05:43 +0200
commitadc0700dc4589e59de2c17a2f8cfc2ba2fb1181f (patch)
treeab6bd44a9b71d8d04b7c8cb8247fb94c57d8e4eb /src/nvim/lua/executor.c
parent1dc9728dbd4cb07f07dbfae92e857452f23a2849 (diff)
downloadrneovim-adc0700dc4589e59de2c17a2f8cfc2ba2fb1181f.tar.gz
rneovim-adc0700dc4589e59de2c17a2f8cfc2ba2fb1181f.tar.bz2
rneovim-adc0700dc4589e59de2c17a2f8cfc2ba2fb1181f.zip
fix(lua): regression with `print()` in headless mode
This is a bunch of hacks so we can override msg_puts_printf specifically while still allowing redirecting and "normal" message flow to happen, as this still has observable side-effects (even with no screen attached, screenstring() is still valid..) fixes #42218
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r--src/nvim/lua/executor.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index a0b982ab0f..d076e53062 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -1119,17 +1119,13 @@ static void nlua_common_free_all_mem(lua_State *lstate)
static void nlua_print_event(void **argv)
{
msg_ext_no_fast();
- if (msg_use_printf() && on_print.type == kCallbackNone) {
- msg_start(); // flush incomplete message
- printf("%.*s\n", (int)(intptr_t)argv[1] - 1, (char *)argv[0]);
- xfree(argv[0]);
- } else {
- HlMessage msg = KV_INITIAL_VALUE;
- HlMessageChunk chunk = { { .data = argv[0], .size = (size_t)(intptr_t)argv[1] - 1 }, 0 };
- kv_push(msg, chunk);
- bool needs_clear = false;
- msg_multihl(NIL, msg, "lua_print", true, false, NULL, &needs_clear);
- }
+ bool raw = msg_use_printf() && !redirecting() && on_print.type == kCallbackNone;
+
+ HlMessage msg = KV_INITIAL_VALUE;
+ HlMessageChunk chunk = { { .data = argv[0], .size = (size_t)(intptr_t)argv[1] - 1 }, 0 };
+ kv_push(msg, chunk);
+ bool needs_clear = false;
+ msg_multihl(NIL, msg, "lua_print", true, false, NULL, &needs_clear, raw);
}
/// Implements Lua print() as a Nvim message.