fix(normal): crash using :norm from vim.ui_attach shell message event #38283

Problem:  'showcmd' buffer is being populated for :norm commands, which
          can result in a recursive uv_run() when called from a msg_show
          vim.ui_attach callback for a shell message.

Solution: The 'showcmd' buffer is never displayed while executing a
          :normal command so prevent unnecessary work, avoiding the crash.
This commit is contained in:
luukvbaal
2026-03-13 14:36:44 +01:00
committed by GitHub
parent f51c54ace6
commit 911337eb3c
2 changed files with 13 additions and 1 deletions

View File

@@ -1973,7 +1973,7 @@ bool add_to_showcmd(int c)
0
};
if (!p_sc || msg_silent != 0) {
if (!p_sc || msg_silent != 0 || ex_normal_busy) {
return false;
}

View File

@@ -404,6 +404,18 @@ describe('vim.ui_attach', function()
feed('<Esc>:<Tab>')
n.assert_alive()
end)
it("does not crash with :norm 'showcmd' from shell message callback #38233", function()
exec_lua(function()
vim.ui_attach(vim.api.nvim_create_namespace(''), { ext_messages = true }, function(event)
if event == 'msg_show' then
vim.api.nvim_command('norm! G')
end
end)
end)
n.command('set showcmd | !echo "foo"')
n.assert_alive()
end)
end)
describe('vim.ui_attach', function()