patch 8.2.2900: QuitPre is triggered before :wq writes the file
Problem: QuitPre is triggered before :wq writes the file, which is
different from other commands.
Solution: Trigger QuitPre after writing the file. (closes #8279)
diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim
index e4293e3..e94071f 100644
--- a/src/testdir/test_writefile.vim
+++ b/src/testdir/test_writefile.vim
@@ -915,4 +915,25 @@
call delete('Xfile3')
endfunc
+" Check that buffer is written before triggering QuitPre
+func Test_wq_quitpre_autocommand()
+ edit Xsomefile
+ call setline(1, 'hello')
+ split
+ let g:seq = []
+ augroup Testing
+ au QuitPre * call add(g:seq, 'QuitPre - ' .. (&modified ? 'modified' : 'not modified'))
+ au BufWritePost * call add(g:seq, 'written')
+ augroup END
+ wq
+ call assert_equal(['written', 'QuitPre - not modified'], g:seq)
+
+ augroup Testing
+ au!
+ augroup END
+ bwipe!
+ unlet g:seq
+ call delete('Xsomefile')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab