mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 14:56:08 +00:00
fix(window): don't make hidden/unfocusable previous window current #36142
Problem: Previous window is made current while it is unfocusable/hidden. Solution: Treat hidden/unfocusable window as an invalid previous window.
This commit is contained in:
@@ -462,7 +462,7 @@ newwindow:
|
||||
// cursor to last accessed (previous) window
|
||||
case 'p':
|
||||
case Ctrl_P:
|
||||
if (!win_valid(prevwin)) {
|
||||
if (!win_valid(prevwin) || prevwin->w_config.hide || !prevwin->w_config.focusable) {
|
||||
beep_flush();
|
||||
} else {
|
||||
win_goto(prevwin);
|
||||
|
@@ -962,6 +962,19 @@ describe('float window', function()
|
||||
eq(1, fn.tabpagewinnr(2))
|
||||
end)
|
||||
|
||||
it('non-visible/focusable is not a valid previous window', function()
|
||||
local win = api.nvim_open_win(0, true, { relative = 'editor', width = 2, height = 2, row = 2, col = 2, focusable = false })
|
||||
command('wincmd p')
|
||||
command('wincmd p')
|
||||
neq(win, api.nvim_get_current_win())
|
||||
api.nvim_win_set_config(win, { focusable = true, hide = true })
|
||||
command('wincmd p')
|
||||
neq(win, api.nvim_get_current_win())
|
||||
api.nvim_win_set_config(win, { hide = false })
|
||||
command('wincmd p')
|
||||
eq(win, api.nvim_get_current_win())
|
||||
end)
|
||||
|
||||
it('no crash for unallocated relative window grid', function()
|
||||
local win = api.nvim_open_win(0, false, { relative = 'editor', row = 0, col = 0, height = 1, width = 1 })
|
||||
exec_lua(function()
|
||||
|
Reference in New Issue
Block a user