fix(window): don't go to unfocusable float when closing (#28455)

This commit is contained in:
zeertzjq 2024-04-22 17:57:49 +08:00 committed by GitHub
parent 2088521263
commit 2cbfa4b9af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -2869,7 +2869,8 @@ int win_close(win_T *win, bool free_buf, bool force)
if (wp == curwin) {
break;
}
if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) {
if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)
&& !(wp->w_floating && !wp->w_config.focusable)) {
curwin = wp;
break;
}

View File

@ -434,6 +434,25 @@ describe('float window', function()
eq(winid, eval('win_getid()'))
end)
it('is not active after closing window when non-focusable #28454', function()
command('copen')
local winid = exec_lua([[
local bufnr = vim.api.nvim_create_buf(false, true)
local opts = {
relative = 'editor',
focusable = false,
height = 5,
width = 5,
col = 5,
row = 5,
}
return vim.api.nvim_open_win(bufnr, false, opts)
]])
command('wincmd t')
command('wincmd q')
neq(winid, curwin())
end)
it('supports windo with focusable and non-focusable floats', function()
local winids = exec_lua([[
local result = {vim.api.nvim_get_current_win()}