Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -19,6 +19,7 @@ if has('timers') call timer_start(100, 'ExitInsertMode') call feedkeys('a', 'x!') call assert_equal(1, g:triggered) + au! CursorHoldI endfunc func Test_cursorhold_insert_ctrl_x() @@ -29,6 +30,7 @@ if has('timers') " CursorHoldI does not trigger after CTRL-X call feedkeys("a\<C-X>", 'x!') call assert_equal(0, g:triggered) + au! CursorHoldI endfunc endif @@ -58,6 +60,7 @@ function Test_bufunload() bwipeout call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li) + au! test_bufunload_group augroup! test_bufunload_group endfunc @@ -120,3 +123,31 @@ func Test_win_tab_autocmd() augroup END unlet g:record endfunc + +func s:AddAnAutocmd() + augroup vimBarTest + au BufReadCmd * echo 'hello' + augroup END + call assert_equal(3, len(split(execute('au vimBarTest'), "\n"))) +endfunc + +func Test_early_bar() + " test that a bar is recognized before the {event} + call s:AddAnAutocmd() + augroup vimBarTest | au! | augroup END + call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) + + call s:AddAnAutocmd() + augroup vimBarTest| au!| augroup END + call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) + + " test that a bar is recognized after the {event} + call s:AddAnAutocmd() + augroup vimBarTest| au!BufReadCmd| augroup END + call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) + + " test that a bar is recognized after the {group} + call s:AddAnAutocmd() + au! vimBarTest|echo 'hello' + call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) +endfunc