From a6ea3a1055a374df36cb037ec548698cd9f56fbd Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Fri, 1 May 2026 16:33:45 +0200 Subject: [PATCH] fix: vim._with may silence all cmdline-errors #34301 Problem: vim._with may silence all cmdline-errors if emsg_silent=true, silent=false. Steps to reproduce: `nvim --clean -u repro.lua`, then `:echoerr 123`, nothing is shown. local api, fn = vim.api, vim.fn -- api.nvim_create_autocmd("CursorMovedC", { api.nvim_create_autocmd("CmdlineChanged", { callback = function(args) if args.match ~= ":" then return end -- vim.cmd([[silent! ]]) vim._with({ emsg_silent = true }, function() -- return api.nvim_parse_cmd(fn.getcmdline(), {}) end) end, }) Solution: Force CMOD_SILENT if CMOD_ERRSILENT. --- src/nvim/lua/stdlib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 1b36da4fbb..c2e8394154 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -622,6 +622,12 @@ static int nlua_with(lua_State *L) int status = 0; int rets = 0; + if (flags & CMOD_ERRSILENT) { + // CMOD_ERRSILENT must imply CMOD_SILENT, otherwise apply_cmdmod() and undo_cmdmod() won't + // work properly. + flags |= CMOD_SILENT; + } + const int save_min_log_level = g_min_log_level; if (log_level >= 0) { g_min_log_level = log_level;