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/window.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 43667377c5..549dd18e4f 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -958,6 +958,11 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) int wmh1; bool did_set_fraction = false; + // aucmd_win should always remain floating + if (new_wp != NULL && new_wp == aucmd_win) { + return FAIL; + } + if (flags & WSP_TOP) { oldwin = firstwin; } else if (flags & WSP_BOT || curwin->w_floating) { -- cgit From 430371da5ba40a791873b30a900ff34da95a9de4 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Tue, 22 Feb 2022 21:06:53 +0000 Subject: 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/window.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/window.c') 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); -- cgit