comparison src/testdir/test_autocmd.vim @ 9653:01c9630e80e0 v7.4.2103

commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 26 20:43:40 2016 +0200 patch 7.4.2103 Problem: Can't have "augroup END" right after ":au!". Solution: Check for the bar character before the command argument.
author Christian Brabandt <cb@256bit.org>
date Tue, 26 Jul 2016 20:45:06 +0200
parents 42a8a81decdf
children a98607bb756c
comparison
equal deleted inserted replaced
9652:1869038e346b 9653:01c9630e80e0
17 au CursorHoldI * let g:triggered += 1 17 au CursorHoldI * let g:triggered += 1
18 set updatetime=20 18 set updatetime=20
19 call timer_start(100, 'ExitInsertMode') 19 call timer_start(100, 'ExitInsertMode')
20 call feedkeys('a', 'x!') 20 call feedkeys('a', 'x!')
21 call assert_equal(1, g:triggered) 21 call assert_equal(1, g:triggered)
22 au! CursorHoldI
22 endfunc 23 endfunc
23 24
24 func Test_cursorhold_insert_ctrl_x() 25 func Test_cursorhold_insert_ctrl_x()
25 let g:triggered = 0 26 let g:triggered = 0
26 au CursorHoldI * let g:triggered += 1 27 au CursorHoldI * let g:triggered += 1
27 set updatetime=20 28 set updatetime=20
28 call timer_start(100, 'ExitInsertMode') 29 call timer_start(100, 'ExitInsertMode')
29 " CursorHoldI does not trigger after CTRL-X 30 " CursorHoldI does not trigger after CTRL-X
30 call feedkeys("a\<C-X>", 'x!') 31 call feedkeys("a\<C-X>", 'x!')
31 call assert_equal(0, g:triggered) 32 call assert_equal(0, g:triggered)
33 au! CursorHoldI
32 endfunc 34 endfunc
33 endif 35 endif
34 36
35 function Test_bufunload() 37 function Test_bufunload()
36 augroup test_bufunload_group 38 augroup test_bufunload_group
56 new 58 new
57 setlocal bufhidden=unload 59 setlocal bufhidden=unload
58 bwipeout 60 bwipeout
59 call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li) 61 call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li)
60 62
63 au! test_bufunload_group
61 augroup! test_bufunload_group 64 augroup! test_bufunload_group
62 endfunc 65 endfunc
63 66
64 " SEGV occurs in older versions. (At least 7.4.2005 or older) 67 " SEGV occurs in older versions. (At least 7.4.2005 or older)
65 function Test_autocmd_bufunload_with_tabnext() 68 function Test_autocmd_bufunload_with_tabnext()
118 augroup testing 121 augroup testing
119 au! 122 au!
120 augroup END 123 augroup END
121 unlet g:record 124 unlet g:record
122 endfunc 125 endfunc
126
127 func s:AddAnAutocmd()
128 augroup vimBarTest
129 au BufReadCmd * echo 'hello'
130 augroup END
131 call assert_equal(3, len(split(execute('au vimBarTest'), "\n")))
132 endfunc
133
134 func Test_early_bar()
135 " test that a bar is recognized before the {event}
136 call s:AddAnAutocmd()
137 augroup vimBarTest | au! | augroup END
138 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
139
140 call s:AddAnAutocmd()
141 augroup vimBarTest| au!| augroup END
142 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
143
144 " test that a bar is recognized after the {event}
145 call s:AddAnAutocmd()
146 augroup vimBarTest| au!BufReadCmd| augroup END
147 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
148
149 " test that a bar is recognized after the {group}
150 call s:AddAnAutocmd()
151 au! vimBarTest|echo 'hello'
152 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
153 endfunc