Problem: WinEnter autocommand may confuse Vim when closing tabpage
(hokorobi)
Solution: Verify that curwin did not change in close_others()
fixes: #18722
closes: #18733
Signed-off-by: Christian Brabandt <cb@256bit.org>
call StopVimInTerminal(buf)
endfunc
+func Test_win_tabclose_autocmd()
+
+ defer CleanUpTestAuGroup()
+ new
+ augroup testing
+ au WinClosed * wincmd p
+ augroup END
+
+ tabnew
+ new
+ new
+
+ call assert_equal(2, tabpagenr('$'))
+ try
+ tabclose
+ catch
+ " should not happen
+ call assert_report("closing tabpage failed")
+ endtry
+ call assert_equal(1, tabpagenr('$'))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1916,
/**/
1915,
/**/
{
win_T *wp;
win_T *nextwp;
+ win_T *old_curwin = curwin;
int r;
if (one_window())
for (wp = firstwin; win_valid(wp); wp = nextwp)
{
nextwp = wp->w_next;
+
+ // autocommands messed this one up
+ if (old_curwin != curwin && win_valid(old_curwin))
+ {
+ curwin = old_curwin;
+ curbuf = curwin->w_buffer;
+ }
+
if (wp == curwin) // don't close current window
continue;