diff --git a/runtime/lua/vim/health.lua b/runtime/lua/vim/health.lua index 2164baf0f8..ee744bcc4a 100644 --- a/runtime/lua/vim/health.lua +++ b/runtime/lua/vim/health.lua @@ -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 diff --git a/test/functional/plugin/health_spec.lua b/test/functional/plugin/health_spec.lua index 7aad3cee03..36819cd83f 100644 --- a/test/functional/plugin/health_spec.lua +++ b/test/functional/plugin/health_spec.lua @@ -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)