mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
fix(window): :close crash if WinClosed from float closes window (#27794)
Problem: :close crash if WinClosed from float closes window. Solution: Check if window has already been closed.
This commit is contained in:
parent
731e7f51ee
commit
9bd4a28079
@ -2560,6 +2560,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, bool force, tab
|
||||
emsg(_("E814: Cannot close window, only autocmd window would remain"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (force || can_close_floating_windows()) {
|
||||
// close the last window until the there are no floating windows
|
||||
while (lastwin->w_floating) {
|
||||
@ -2573,6 +2574,10 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, bool force, tab
|
||||
emsg(e_floatonly);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!win_valid_any_tab(win)) {
|
||||
return true; // window already closed by autocommands
|
||||
}
|
||||
}
|
||||
|
||||
buf_T *old_curbuf = curbuf;
|
||||
@ -2591,10 +2596,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, bool force, tab
|
||||
// that below.
|
||||
goto_tabpage_tp(alt_tabpage(), false, true);
|
||||
|
||||
// save index for tabclosed event
|
||||
char prev_idx[NUMBUFLEN];
|
||||
snprintf(prev_idx, NUMBUFLEN, "%i", tabpage_index(prev_curtab));
|
||||
|
||||
// Safety check: Autocommands may have closed the window when jumping
|
||||
// to the other tab page.
|
||||
if (valid_tabpage(prev_curtab) && prev_curtab->tp_firstwin == win) {
|
||||
|
@ -908,6 +908,21 @@ describe('float window', function()
|
||||
command('close')
|
||||
assert_alive()
|
||||
end)
|
||||
|
||||
it('does not crash if WinClosed from floating windows closes it', function()
|
||||
exec([[
|
||||
tabnew
|
||||
let g:buf = bufnr()
|
||||
new
|
||||
let s:win = win_getid()
|
||||
call nvim_win_set_config(s:win,
|
||||
\ #{relative: 'editor', row: 5, col: 5, width: 5, height: 5})
|
||||
wincmd t
|
||||
exe $"autocmd WinClosed {s:win} 1close"
|
||||
]])
|
||||
command('close')
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
local function with_ext_multigrid(multigrid)
|
||||
|
Loading…
Reference in New Issue
Block a user