Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 9106:97a9538c37ff v7.4.1837
commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue May 24 16:07:40 2016 +0200
patch 7.4.1837
Problem: The BufUnload event is triggered twice, when :bunload is used with
set to or .
Solution: Do not trigger the event when ml_mfp is NULL. (Hirohito Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 24 May 2016 16:15:07 +0200 |
parents | c07caeb90a35 |
children | 073aebdba121 |
comparison
equal
deleted
inserted
replaced
9105:06f8149137c9 | 9106:97a9538c37ff |
---|---|
5 | 5 |
6 " This script will never reach the main loop, can't check if v:vim_did_enter | 6 " This script will never reach the main loop, can't check if v:vim_did_enter |
7 " becomes one. | 7 " becomes one. |
8 endfunc | 8 endfunc |
9 | 9 |
10 if !has('timers') | 10 if has('timers') |
11 finish | 11 func ExitInsertMode(id) |
12 call feedkeys("\<Esc>") | |
13 endfunc | |
14 | |
15 func Test_cursorhold_insert() | |
16 let g:triggered = 0 | |
17 au CursorHoldI * let g:triggered += 1 | |
18 set updatetime=20 | |
19 call timer_start(100, 'ExitInsertMode') | |
20 call feedkeys('a', 'x!') | |
21 call assert_equal(1, g:triggered) | |
22 endfunc | |
23 | |
24 func Test_cursorhold_insert_ctrl_x() | |
25 let g:triggered = 0 | |
26 au CursorHoldI * let g:triggered += 1 | |
27 set updatetime=20 | |
28 call timer_start(100, 'ExitInsertMode') | |
29 " CursorHoldI does not trigger after CTRL-X | |
30 call feedkeys("a\<C-X>", 'x!') | |
31 call assert_equal(0, g:triggered) | |
32 endfunc | |
12 endif | 33 endif |
13 | 34 |
14 func ExitInsertMode(id) | 35 function Test_bufunload() |
15 call feedkeys("\<Esc>") | 36 augroup test_bufunload_group |
37 autocmd! | |
38 autocmd BufUnload * call add(s:li, "bufunload") | |
39 autocmd BufDelete * call add(s:li, "bufdelete") | |
40 autocmd BufWipeout * call add(s:li, "bufwipeout") | |
41 augroup END | |
42 | |
43 let s:li=[] | |
44 new | |
45 setlocal bufhidden= | |
46 bunload | |
47 call assert_equal(["bufunload", "bufdelete"], s:li) | |
48 | |
49 let s:li=[] | |
50 new | |
51 setlocal bufhidden=delete | |
52 bunload | |
53 call assert_equal(["bufunload", "bufdelete"], s:li) | |
54 | |
55 let s:li=[] | |
56 new | |
57 setlocal bufhidden=unload | |
58 bwipeout | |
59 call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li) | |
60 | |
61 augroup! test_bufunload_group | |
16 endfunc | 62 endfunc |
17 | |
18 func Test_cursorhold_insert() | |
19 let g:triggered = 0 | |
20 au CursorHoldI * let g:triggered += 1 | |
21 set updatetime=20 | |
22 call timer_start(100, 'ExitInsertMode') | |
23 call feedkeys('a', 'x!') | |
24 call assert_equal(1, g:triggered) | |
25 endfunc | |
26 | |
27 func Test_cursorhold_insert_ctrl_x() | |
28 let g:triggered = 0 | |
29 au CursorHoldI * let g:triggered += 1 | |
30 set updatetime=20 | |
31 call timer_start(100, 'ExitInsertMode') | |
32 " CursorHoldI does not trigger after CTRL-X | |
33 call feedkeys("a\<C-X>", 'x!') | |
34 call assert_equal(0, g:triggered) | |
35 endfunc |