fix(:checkhealth): open after current tabpage (#40319)

This commit is contained in:
zeertzjq
2026-06-19 17:45:21 +08:00
committed by GitHub
parent 0639f6e41a
commit 1e30f5d242
2 changed files with 13 additions and 2 deletions

View File

@@ -427,7 +427,7 @@ function M._check(eap)
elseif emptybuf then
vim.cmd.buffer(bufnr)
else
vim.cmd.sbuffer { bufnr, mods = { tab = 1 } }
vim.cmd.sbuffer { bufnr, mods = { tab = vim.api.nvim_tabpage_get_number(0) } }
end
end

View File

@@ -507,7 +507,7 @@ describe(':checkhealth window', function()
end)
end
it('opens in tab', function()
it('opens in new tabpage after the current one', function()
-- create an empty buffer called "my_buff"
api.nvim_create_buf(false, true)
command('file my_buff')
@@ -530,5 +530,16 @@ describe(':checkhealth window', function()
]])
local buffers_per_tab = fn.CollectBuffersPerTab()
eq(buffers_per_tab, { tab1 = { 'my_buff' }, tab2 = { 'health://' } })
command('bwipe')
command('tab split | tab split | tab split | tabprevious')
command('checkhealth success1')
buffers_per_tab = fn.CollectBuffersPerTab()
eq(buffers_per_tab, {
tab1 = { 'my_buff' },
tab2 = { 'my_buff' },
tab3 = { 'my_buff' },
tab4 = { 'health://' },
tab5 = { 'my_buff' },
})
end)
end)