diff src/testdir/test_quickfix.vim @ 10056:21f685af3fc1 v7.4.2299

commit https://github.com/vim/vim/commit/04c4ce650f9e533cd35b2aa6803f4d354d3ec7aa Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 1 15:45:58 2016 +0200 patch 7.4.2299 Problem: QuickFixCmdPre and QuickFixCmdPost autocommands are not always triggered. Solution: Also trigger on ":expr", ":cbuffer", etc. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Thu, 01 Sep 2016 16:00:09 +0200
parents e24aa20d815c
children 197795e3530d
line wrap: on
line diff
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -1554,3 +1554,38 @@ function Test_qf_property()
     call Xproperty_tests('c')
     call Xproperty_tests('l')
 endfunction
+
+" Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands
+function QfAutoCmdHandler(loc, cmd)
+  call add(g:acmds, a:loc . a:cmd)
+endfunction
+
+function Test_Autocmd()
+  autocmd QuickFixCmdPre * call QfAutoCmdHandler('pre', expand('<amatch>'))
+  autocmd QuickFixCmdPost * call QfAutoCmdHandler('post', expand('<amatch>'))
+
+  let g:acmds = []
+  cexpr "F1:10:Line 10"
+  caddexpr "F1:20:Line 20"
+  cgetexpr "F1:30:Line 30"
+  enew! | call append(0, "F2:10:Line 10")
+  cbuffer!
+  enew! | call append(0, "F2:20:Line 20")
+  cgetbuffer
+  enew! | call append(0, "F2:30:Line 30")
+  caddbuffer
+
+  let l = ['precexpr',
+	      \ 'postcexpr',
+	      \ 'precaddexpr',
+	      \ 'postcaddexpr',
+	      \ 'precgetexpr',
+	      \ 'postcgetexpr',
+	      \ 'precbuffer',
+	      \ 'postcbuffer',
+	      \ 'precgetbuffer',
+	      \ 'postcgetbuffer',
+	      \ 'precaddbuffer',
+	      \ 'postcaddbuffer']
+  call assert_equal(l, g:acmds)
+endfunction