From 430371da5ba40a791873b30a900ff34da95a9de4 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 22 Feb 2022 21:06:53 +0000 Subject: [PATCH] refactor(aucmd_win): remove need to restore window layout There are some places that mess with the window layout in preparation for moving a window to a different split (win_split_ins called with new_wp != NULL). This means the window layout can change slightly even if win_split_ins fails. This is why it was still needed to restore the window layout in aucmd_{prep,rest}buf even if we disallow win_split_ins from making aucmd_win non-floating by moving it into a split. We can just skip messing with the layout in such places if we're dealing with the aucmd_win. --- src/nvim/autocmd.c | 3 --- src/nvim/eval/funcs.c | 2 +- src/nvim/window.c | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index cdaa120644..9117dde089 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1147,7 +1147,6 @@ 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); @@ -1213,8 +1212,6 @@ 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); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 3763390c22..c5b01701de 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -4242,7 +4242,7 @@ static void win_move_into_split(win_T *wp, win_T *targetwin, int size, int flags int height = wp->w_height; win_T *oldwin = curwin; - if (wp == targetwin) { + if (wp == targetwin || wp == aucmd_win) { return; } diff --git a/src/nvim/window.c b/src/nvim/window.c index 549dd18e4f..83048d911f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1838,6 +1838,9 @@ static void win_totop(int size, int flags) beep_flush(); return; } + if (curwin == aucmd_win) { + return; + } if (curwin->w_floating) { ui_comp_remove_grid(&curwin->w_grid_alloc);