From 2deffb5ea8e2fc8dec2cc805dbed849ad6afa4b4 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 31 Dec 2021 09:32:04 +0000 Subject: fix(aucmd_win): ensure aucmd_win stays floating Nvim uses a floating window for the autocmd window, but in certain situations, it can be made non-floating (`:wincmd J`), which can cause issues due to the previous setup and cleanup logic for a non-floating aucmd_win being removed from aucmd_prepbuf and aucmd_restbuf. This can cause glitchiness and crashes due to the aucmd_win's frame being invalid after closing its tabpage, for example. Ensure aucmd_win cannot be made non-floating. The only place this happens is in win_split_ins if new_wp != NULL. --- src/nvim/autocmd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/autocmd.c') diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 9117dde089..cdaa120644 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1147,6 +1147,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) globaldir = NULL; block_autocmds(); // We don't want BufEnter/WinEnter autocommands. + make_snapshot(SNAP_AUCMD_IDX); if (need_append) { win_append(lastwin, aucmd_win); pmap_put(handle_T)(&window_handles, aucmd_win->handle, aucmd_win); @@ -1212,6 +1213,8 @@ win_found: close_tabpage(curtab); } + restore_snapshot(SNAP_AUCMD_IDX, false); + win_comp_pos(); // recompute window positions unblock_autocmds(); win_T *const save_curwin = win_find_by_handle(aco->save_curwin_handle); -- cgit