patch 7.4.2312
Problem:    Crash when autocommand moves to another tab. (Dominique Pelle)
Solution:   When navigating to another window halfway the :edit command go
            back to the right window.
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index 7bdea0b..0bf7d05 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -218,7 +218,7 @@
   bw!
 endfunction
 
-func Test_tabnext_on_buf_unload()
+func Test_tabnext_on_buf_unload1()
   " This once caused a crash
   new
   tabedit
@@ -227,7 +227,19 @@
   q
 
   while tabpagenr('$') > 1
-    quit
+    bwipe!
+  endwhile
+endfunc
+
+func Test_tabnext_on_buf_unload2()
+  " This once caused a crash
+  tabedit
+  autocmd BufUnload <buffer> tabnext
+  file x
+  edit y
+
+  while tabpagenr('$') > 1
+    bwipe!
   endwhile
 endfunc