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.
This commit is contained in:
altermo
2026-05-01 16:33:45 +02:00
committed by GitHub
parent ad2cf23435
commit a6ea3a1055
+6
View File
@@ -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;