patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Problem: A QuitPre autocommand may get the wrong file name.
Solution: Pass the buffer being closed to apply_autocmds(). (Rich Howe)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 593d1cc..f5a2289 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -779,3 +779,17 @@
" check that bufinfo doesn't contain a pointer to freed memory
call test_garbagecollect_now()
endfunc
+
+func Test_QuitPre()
+ edit Xfoo
+ let winid = win_getid(winnr())
+ split Xbar
+ au! QuitPre * let g:afile = expand('<afile>')
+ " Close the other window, <afile> should be correct.
+ exe win_id2win(winid) . 'q'
+ call assert_equal('Xfoo', g:afile)
+
+ unlet g:afile
+ bwipe Xfoo
+ bwipe Xbar
+endfunc