annotate src/testdir/test_autocmd.vim @ 10114:aa2219afd1c2 v7.4.2328

commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 4 21:33:09 2016 +0200 patch 7.4.2328 Problem: Crash when BufWinLeave autocmd goes to another tab page. (Hirohito Higashi) Solution: Make close_buffer() go back to the right window.
author Christian Brabandt <cb@256bit.org>
date Sun, 04 Sep 2016 21:45:06 +0200
parents 58e6dd1d8be3
children b67088aae933
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8738
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for autocommands
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 func Test_vim_did_enter()
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 call assert_false(v:vim_did_enter)
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " This script will never reach the main loop, can't check if v:vim_did_enter
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " becomes one.
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endfunc
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
9
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
10 if has('timers')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
11 func ExitInsertMode(id)
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
12 call feedkeys("\<Esc>")
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
13 endfunc
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
14
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
15 func Test_cursorhold_insert()
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
16 let g:triggered = 0
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
17 au CursorHoldI * let g:triggered += 1
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
18 set updatetime=20
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
19 call timer_start(100, 'ExitInsertMode')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
20 call feedkeys('a', 'x!')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
21 call assert_equal(1, g:triggered)
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
22 au! CursorHoldI
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
23 endfunc
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
24
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
25 func Test_cursorhold_insert_ctrl_x()
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
26 let g:triggered = 0
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
27 au CursorHoldI * let g:triggered += 1
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
28 set updatetime=20
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
29 call timer_start(100, 'ExitInsertMode')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
30 " CursorHoldI does not trigger after CTRL-X
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
31 call feedkeys("a\<C-X>", 'x!')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
32 call assert_equal(0, g:triggered)
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
33 au! CursorHoldI
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
34 endfunc
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
35 endif
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
36
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
37 function Test_bufunload()
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
38 augroup test_bufunload_group
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
39 autocmd!
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
40 autocmd BufUnload * call add(s:li, "bufunload")
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
41 autocmd BufDelete * call add(s:li, "bufdelete")
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
42 autocmd BufWipeout * call add(s:li, "bufwipeout")
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
43 augroup END
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
44
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
45 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
46 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
47 setlocal bufhidden=
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
48 bunload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
49 call assert_equal(["bufunload", "bufdelete"], s:li)
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
50
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
51 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
52 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
53 setlocal bufhidden=delete
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
54 bunload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
55 call assert_equal(["bufunload", "bufdelete"], s:li)
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
56
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
57 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
58 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
59 setlocal bufhidden=unload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
60 bwipeout
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
61 call assert_equal(["bufunload", "bufdelete", "bufwipeout"], s:li)
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
62
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
63 au! test_bufunload_group
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
64 augroup! test_bufunload_group
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
65 endfunc
9450
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
66
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
67 " SEGV occurs in older versions. (At least 7.4.2005 or older)
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
68 function Test_autocmd_bufunload_with_tabnext()
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
69 tabedit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
70 tabfirst
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
71
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
72 augroup test_autocmd_bufunload_with_tabnext_group
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
73 autocmd!
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
74 autocmd BufUnload <buffer> tabnext
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
75 augroup END
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
76
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
77 quit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
78 call assert_equal(2, tabpagenr('$'))
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
79
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
80 autocmd! test_autocmd_bufunload_with_tabnext_group
9450
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
81 augroup! test_autocmd_bufunload_with_tabnext_group
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
82 tablast
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
83 quit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
84 endfunc
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
85
10114
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
86 function Test_autocmd_bufwinleave_with_tabfirst()
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
87 tabedit
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
88 augroup sample
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
89 autocmd!
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
90 autocmd BufWinLeave <buffer> tabfirst
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
91 augroup END
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
92 call setline(1, ['a', 'b', 'c'])
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
93 edit! a.txt
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
94 endfunc
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
95
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
96 " SEGV occurs in older versions. (At least 7.4.2321 or older)
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
97 function Test_autocmd_bufunload_avoiding_SEGV_01()
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
98 split aa.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
99 let lastbuf = bufnr('$')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
100
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
101 augroup test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
102 autocmd!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
103 exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
104 augroup END
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
105
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
106 call assert_fails('edit bb.txt', 'E937:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
107
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
108 autocmd! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
109 augroup! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
110 bwipe! aa.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
111 bwipe! bb.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
112 endfunc
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
113
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
114 " SEGV occurs in older versions. (At least 7.4.2321 or older)
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
115 function Test_autocmd_bufunload_avoiding_SEGV_02()
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
116 setlocal buftype=nowrite
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
117 let lastbuf = bufnr('$')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
118
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
119 augroup test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
120 autocmd!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
121 exe 'autocmd BufUnload <buffer> ' . (lastbuf + 1) . 'bwipeout!'
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
122 augroup END
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
123
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
124 normal! i1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
125 call assert_fails('edit a.txt', 'E517:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
126 call feedkeys("\<CR>")
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
127
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
128 autocmd! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
129 augroup! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
130 bwipe! a.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
131 endfunc
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
132
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
133 func Test_win_tab_autocmd()
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
134 let g:record = []
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
135
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
136 augroup testing
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
137 au WinNew * call add(g:record, 'WinNew')
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
138 au WinEnter * call add(g:record, 'WinEnter')
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
139 au WinLeave * call add(g:record, 'WinLeave')
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
140 au TabNew * call add(g:record, 'TabNew')
9599
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
141 au TabClosed * call add(g:record, 'TabClosed')
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
142 au TabEnter * call add(g:record, 'TabEnter')
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
143 au TabLeave * call add(g:record, 'TabLeave')
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
144 augroup END
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
145
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
146 split
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
147 tabnew
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
148 close
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
149 close
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
150
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
151 call assert_equal([
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
152 \ 'WinLeave', 'WinNew', 'WinEnter',
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
153 \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter',
9599
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
154 \ 'WinLeave', 'TabLeave', 'TabClosed', 'WinEnter', 'TabEnter',
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
155 \ 'WinLeave', 'WinEnter'
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
156 \ ], g:record)
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
157
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
158 let g:record = []
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
159 tabnew somefile
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
160 tabnext
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
161 bwipe somefile
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
162
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
163 call assert_equal([
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
164 \ 'WinLeave', 'TabLeave', 'WinNew', 'WinEnter', 'TabNew', 'TabEnter',
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
165 \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter',
9599
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
166 \ 'TabClosed'
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
167 \ ], g:record)
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
168
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
169 augroup testing
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
170 au!
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
171 augroup END
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
172 unlet g:record
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
173 endfunc
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
174
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
175 func s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
176 augroup vimBarTest
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
177 au BufReadCmd * echo 'hello'
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
178 augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
179 call assert_equal(3, len(split(execute('au vimBarTest'), "\n")))
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
180 endfunc
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
181
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
182 func Test_early_bar()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
183 " test that a bar is recognized before the {event}
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
184 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
185 augroup vimBarTest | au! | augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
186 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
187
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
188 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
189 augroup vimBarTest| au!| augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
190 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
191
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
192 " test that a bar is recognized after the {event}
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
193 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
194 augroup vimBarTest| au!BufReadCmd| augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
195 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
196
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
197 " test that a bar is recognized after the {group}
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
198 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
199 au! vimBarTest|echo 'hello'
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
200 call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
201 endfunc
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
202
10058
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
203 func RemoveGroup()
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
204 autocmd! StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
205 augroup! StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
206 endfunc
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
207
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
208 func Test_augroup_warning()
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
209 augroup TheWarning
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
210 au VimEnter * echo 'entering'
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
211 augroup END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
212 call assert_true(match(execute('au VimEnter'), "TheWarning.*VimEnter") >= 0)
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
213 redir => res
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
214 augroup! TheWarning
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
215 redir END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
216 call assert_true(match(res, "W19:") >= 0)
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
217 call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
218
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
219 " check "Another" does not take the pace of the deleted entry
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
220 augroup Another
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
221 augroup END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
222 call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
10058
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
223
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
224 " no warning for postpone aucmd delete
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
225 augroup StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
226 au VimEnter * call RemoveGroup()
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
227 augroup END
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
228 call assert_true(match(execute('au VimEnter'), "StartOK.*VimEnter") >= 0)
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
229 redir => res
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
230 doautocmd VimEnter
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
231 redir END
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
232 call assert_true(match(res, "W19:") < 0)
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
233 au! VimEnter
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
234 endfunc
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
235
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
236 func Test_augroup_deleted()
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
237 " This caused a crash before E936 was introduced
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
238 augroup x
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
239 call assert_fails('augroup! x', 'E936:')
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
240 au VimEnter * echo
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
241 augroup end
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
242 augroup! x
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
243 call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
244 au! VimEnter
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
245 endfunc
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
246
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
247 " Tests for autocommands on :close command.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
248 " This used to be in test13.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
249 func Test_three_windows()
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
250 " Write three files and open them, each in a window.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
251 " Then go to next window, with autocommand that deletes the previous one.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
252 " Do this twice, writing the file.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
253 e! Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
254 call setline(1, 'testje1')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
255 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
256 sp Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
257 call setline(1, 'testje2')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
258 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
259 sp Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
260 call setline(1, 'testje3')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
261 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
262 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
263 au WinLeave Xtestje2 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
264 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
265 call assert_equal('Xtestje1', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
266
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
267 au WinLeave Xtestje1 bwipe Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
268 close
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
269 call assert_equal('Xtestje1', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
270
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
271 " Test deleting the buffer on a Unload event. If this goes wrong there
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
272 " will be the ATTENTION prompt.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
273 e Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
274 au!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
275 au! BufUnload Xtestje1 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
276 call assert_fails('e Xtestje3', 'E937:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
277 call assert_equal('Xtestje3', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
278
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
279 e Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
280 sp Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
281 call assert_fails('e', 'E937:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
282 call assert_equal('Xtestje2', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
283
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
284 " Test changing buffers in a BufWipeout autocommand. If this goes wrong
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
285 " there are ml_line errors and/or a Crash.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
286 au!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
287 only
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
288 e Xanother
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
289 e Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
290 bwipe Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
291 bwipe Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
292 au BufWipeout Xtestje1 buf Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
293 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
294 call assert_equal('Xanother', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
295
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
296 only
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
297 help
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
298 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
299 1quit
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
300 call assert_equal('Xanother', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
301
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
302 au!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
303 call delete('Xtestje1')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
304 call delete('Xtestje2')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
305 call delete('Xtestje3')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
306 endfunc