diff --git a/runtime/lua/vim/_core/ui2.lua b/runtime/lua/vim/_core/ui2.lua index 58b2331cd3..14211e333e 100644 --- a/runtime/lua/vim/_core/ui2.lua +++ b/runtime/lua/vim/_core/ui2.lua @@ -237,8 +237,12 @@ function M.enable(opts) api.nvim_create_autocmd({ 'VimResized', 'TabEnter' }, { group = M.augroup, - callback = function() + callback = function(ev) M.check_targets() + -- After a tabpage was closed unhide the msg window on the current tabpage. + if ev.event == 'TabEnter' and next(M.msg.msg.ids) ~= nil then + api.nvim_win_set_config(M.wins.msg, { hide = false, width = M.msg.msg.width }) + end M.msg.set_pos() end, desc = 'Set cmdline and message window dimensions after shell resize or tabpage change.', diff --git a/test/functional/ui/messages2_spec.lua b/test/functional/ui/messages2_spec.lua index 7a1afc2cfd..0c3ebb1937 100644 --- a/test/functional/ui/messages2_spec.lua +++ b/test/functional/ui/messages2_spec.lua @@ -977,4 +977,22 @@ describe('messages2', function() foo | ]]) end) + + it('message survives after closing tabpage without error #39055', function() + set_msg_target_zero_ch() + command('tabnew') + command('echo "hello"') + screen:expect([[ + {24: [No Name] }{5: [No Name] }{2: }{24:X}| + ^ | + {1:~ }|*11 + {1:~ }{4:hello}| + ]]) + command('quit!') + screen:expect([[ + ^ | + {1:~ }|*12 + {1:~ }{4:hello}| + ]]) + end) end)