fix(window.c): win_close from other tabpage #15454

Fix #15313
This commit is contained in:
notomo 2021-08-23 07:27:20 +09:00 committed by GitHub
parent da5d023c97
commit 90b2da16ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -2709,7 +2709,11 @@ static win_T *win_free_mem(
// When deleting the current window of another tab page select a new
// current window.
if (tp != NULL && win == tp->tp_curwin) {
tp->tp_curwin = wp;
if (win_valid(tp->tp_prevwin) && tp->tp_prevwin != win) {
tp->tp_curwin = tp->tp_prevwin;
} else {
tp->tp_curwin = tp->tp_firstwin;
}
}
return wp;

View File

@ -347,6 +347,21 @@ describe('API/win', function()
eq(2, #meths.list_wins())
eq('', funcs.getcmdwintype())
end)
it('closing current (float) window of another tabpage #15313', function()
command('tabedit')
eq(2, eval('tabpagenr()'))
local win = meths.open_win(0, true, {
relative='editor', row=10, col=10, width=50, height=10
})
local tabpage = eval('tabpagenr()')
command('tabprevious')
eq(1, eval('tabpagenr()'))
meths.win_close(win, false)
eq(1001, meths.tabpage_get_win(tabpage).id)
helpers.assert_alive()
end)
end)
describe('hide', function()