From b6a3ad3979cc187fe59d57091c0434a7d3a937c1 Mon Sep 17 00:00:00 2001 From: "neovim-backports[bot]" <175700243+neovim-backports[bot]@users.noreply.github.com> Date: Wed, 22 Apr 2026 13:43:04 +0000 Subject: [PATCH] backport: fix(ui2): ensure msg window is visible after closing tab (#39245) fix(ui2): ensure msg window is visible after closing tab Problem: After closing a tabpage while the msg window is showing a message, it is hidden while the msg window still contains a message. Solution: Unhide the msg window after entering a tabpage and it still contains a message. (cherry picked from commit 607fcfb37acd78b0e26c35acb463093957d94c45) Co-authored-by: Luuk van Baal Co-authored-by: Linykq --- runtime/lua/vim/_core/ui2.lua | 6 +++++- test/functional/ui/messages2_spec.lua | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) 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)