patch 9.1.1393: missing test for switching buffers and reusing curbuf
Problem: The check in buf_freeall that restores curwin subtly prevents
leaving an unloaded buffer in a window when reusing curbuf, if
autocommands switch to a different buffer.
Solution: Add a test case that covers this. Also ensure splitting isn't
possible, as that could do the same (Sean Dewar)
closes: #17325
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/buffer.c b/src/buffer.c
index 49ec77c..48e8cb6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -909,7 +909,7 @@
// If the buffer was in curwin and the window has changed, go back to that
// window, if it still exists. This avoids that ":edit x" triggering a
// "tabnext" BufUnload autocmd leaves a window behind without a buffer.
- if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
+ if (is_curwin && curwin != the_curwin && win_valid_any_tab(the_curwin))
{
block_autocmds();
goto_tabpage_win(the_curtab, the_curwin);