From ca6a8ac93c6425e0480fc4b4efa8519701ce2394 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 29 May 2021 09:59:33 -0400 Subject: vim-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 vim/vim#8279) https://github.com/vim/vim/commit/1174b018a6d705ddb8c04f3d21f78ae760aa0856 --- src/nvim/testdir/test_writefile.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/testdir/test_writefile.vim') diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index c7710ff198..6922e2185d 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -361,4 +361,25 @@ func Test_write_file_encoding() %bw! 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 -- cgit