fix(floatwin): don't use same window as altwin (#40748)

Fixes a regression from #34486
Fix #40745

(cherry picked from commit 39bc59a8f1)
This commit is contained in:
zeertzjq
2026-07-15 13:59:45 +08:00
committed by github-actions[bot]
parent a8d7292de3
commit 9ea90ec35a
2 changed files with 15 additions and 9 deletions

View File

@@ -710,18 +710,13 @@ describe('API/win', function()
eq(true, api.nvim_win_is_valid(otherwin))
end)
it('closing current (float) window of another tabpage #15313', function()
it('closing current (float) window of another tabpage #15313 #40745', function()
command('tabedit')
command('botright split')
local prevwin = curwin()
eq(2, eval('tabpagenr()'))
local win = api.nvim_open_win(0, true, {
relative = 'editor',
row = 10,
col = 10,
width = 50,
height = 10,
})
local opts = { relative = 'editor', row = 10, col = 10, width = 50, height = 10 }
local win = vim.api.nvim_open_win(0, true, opts)
local tab = eval('tabpagenr()')
command('tabprevious')
eq(1, eval('tabpagenr()'))
@@ -729,6 +724,17 @@ describe('API/win', function()
eq(prevwin, api.nvim_tabpage_get_win(tab))
assert_alive()
command('tabnext')
local win1 = api.nvim_open_win(0, true, opts)
local win2 = api.nvim_open_win(0, true, opts)
command('tabprevious')
-- win1 becomes the tabpage's current window after win2 is closed
api.nvim_win_close(win2, false)
api.nvim_win_close(win1, false)
eq(prevwin, api.nvim_tabpage_get_win(tab))
assert_alive()
end)
it('closing a float does not enter unfocusable or hidden prevwin', function()