diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 9f10876a11..d45b4a4a28 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -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; } diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index b97fe37720..aa90c810c8 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -404,6 +404,18 @@ describe('vim.ui_attach', function() feed(':') 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()