annotate src/testdir/test_autocmd.vim @ 12680:429bf1b9292f v8.0.1218

patch 8.0.1218: writing to freed memory in autocmd commit https://github.com/vim/vim/commit/8d84ff1a3c8cfe59399d3f675ec080066582fdb6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 26 16:42:16 2017 +0200 patch 8.0.1218: writing to freed memory in autocmd Problem: Writing to freed memory in autocmd. Solution: Make a copy of the tag line. (Dominique Pelle, closes https://github.com/vim/vim/issues/2245)
author Christian Brabandt <cb@256bit.org>
date Thu, 26 Oct 2017 16:45:05 +0200
parents 15f0f9f16cd9
children 03a6aeea2096
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
11197
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 10575
diff changeset
3
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
4 func! s:cleanup_buffers() abort
10242
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
5 for bnr in range(1, bufnr('$'))
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
6 if bufloaded(bnr) && bufnr('%') != bnr
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
7 execute 'bd! ' . bnr
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
8 endif
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
9 endfor
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
10 endfunc
10242
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
11
8738
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 func Test_vim_did_enter()
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_false(v:vim_did_enter)
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 " 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
16 " becomes one.
e770986c855a commit https://github.com/vim/vim/commit/1473551a4457d4920b235eeeb9f279e196ee7225
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 endfunc
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
18
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
19 if has('timers')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
20 func ExitInsertMode(id)
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
21 call feedkeys("\<Esc>")
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
22 endfunc
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
23
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
24 func Test_cursorhold_insert()
10151
0be17a56e65f commit https://github.com/vim/vim/commit/f18c4dbbe545757ce93563b25380e6f010340b4e
Christian Brabandt <cb@256bit.org>
parents: 10141
diff changeset
25 " Need to move the cursor.
0be17a56e65f commit https://github.com/vim/vim/commit/f18c4dbbe545757ce93563b25380e6f010340b4e
Christian Brabandt <cb@256bit.org>
parents: 10141
diff changeset
26 call feedkeys("ggG", "xt")
0be17a56e65f commit https://github.com/vim/vim/commit/f18c4dbbe545757ce93563b25380e6f010340b4e
Christian Brabandt <cb@256bit.org>
parents: 10141
diff changeset
27
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
28 let g:triggered = 0
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
29 au CursorHoldI * let g:triggered += 1
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
30 set updatetime=20
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
31 call timer_start(100, 'ExitInsertMode')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
32 call feedkeys('a', 'x!')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
33 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
34 au! CursorHoldI
10141
b67088aae933 commit https://github.com/vim/vim/commit/aeac9006d5d14910f214f09df52c026a5936e737
Christian Brabandt <cb@256bit.org>
parents: 10114
diff changeset
35 set updatetime&
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
36 endfunc
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
37
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
38 func Test_cursorhold_insert_ctrl_x()
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
39 let g:triggered = 0
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
40 au CursorHoldI * let g:triggered += 1
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
41 set updatetime=20
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
42 call timer_start(100, 'ExitInsertMode')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
43 " 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
44 call feedkeys("a\<C-X>", 'x!')
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
45 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
46 au! CursorHoldI
10141
b67088aae933 commit https://github.com/vim/vim/commit/aeac9006d5d14910f214f09df52c026a5936e737
Christian Brabandt <cb@256bit.org>
parents: 10114
diff changeset
47 set updatetime&
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
48 endfunc
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
49 endif
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
50
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
51 func Test_bufunload()
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
52 augroup test_bufunload_group
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
53 autocmd!
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
54 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
55 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
56 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
57 augroup END
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
58
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
59 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
60 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
61 setlocal bufhidden=
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
62 bunload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
63 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
64
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
65 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
66 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
67 setlocal bufhidden=delete
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
68 bunload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
69 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
70
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
71 let s:li=[]
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
72 new
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
73 setlocal bufhidden=unload
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
74 bwipeout
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
75 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
76
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
77 au! test_bufunload_group
9106
97a9538c37ff commit https://github.com/vim/vim/commit/c67e89213476b5f4756d92208b57ce9ef4a4cf24
Christian Brabandt <cb@256bit.org>
parents: 8947
diff changeset
78 augroup! test_bufunload_group
8947
c07caeb90a35 commit https://github.com/vim/vim/commit/40b1b5443c88fab77f1f7c6f9e801f7ffdb7e0a8
Christian Brabandt <cb@256bit.org>
parents: 8738
diff changeset
79 endfunc
9450
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
80
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
81 " SEGV occurs in older versions. (At least 7.4.2005 or older)
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
82 func Test_autocmd_bufunload_with_tabnext()
9450
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
83 tabedit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
84 tabfirst
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
85
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
86 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
87 autocmd!
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
88 autocmd BufUnload <buffer> tabnext
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
89 augroup END
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
90
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
91 quit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
92 call assert_equal(2, tabpagenr('$'))
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
93
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
94 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
95 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
96 tablast
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
97 quit
073aebdba121 commit https://github.com/vim/vim/commit/30445cb6e94698d212ba866ef3e4022ac625540a
Christian Brabandt <cb@256bit.org>
parents: 9106
diff changeset
98 endfunc
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
99
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
100 func Test_autocmd_bufwinleave_with_tabfirst()
10114
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
101 tabedit
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
102 augroup sample
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
103 autocmd!
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
104 autocmd BufWinLeave <buffer> tabfirst
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
105 augroup END
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
106 call setline(1, ['a', 'b', 'c'])
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
107 edit! a.txt
10151
0be17a56e65f commit https://github.com/vim/vim/commit/f18c4dbbe545757ce93563b25380e6f010340b4e
Christian Brabandt <cb@256bit.org>
parents: 10141
diff changeset
108 tabclose
10114
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
109 endfunc
aa2219afd1c2 commit https://github.com/vim/vim/commit/f9e687e0681a250e1549ab27b6c7ef2c500395e3
Christian Brabandt <cb@256bit.org>
parents: 10106
diff changeset
110
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
111 " SEGV occurs in older versions. (At least 7.4.2321 or older)
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
112 func Test_autocmd_bufunload_avoiding_SEGV_01()
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
113 split aa.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
114 let lastbuf = bufnr('$')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
115
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
116 augroup test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
117 autocmd!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
118 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
119 augroup END
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
120
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
121 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
122
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
123 autocmd! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
124 augroup! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
125 bwipe! aa.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
126 bwipe! bb.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
127 endfunc
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
128
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
129 " SEGV occurs in older versions. (At least 7.4.2321 or older)
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
130 func Test_autocmd_bufunload_avoiding_SEGV_02()
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
131 setlocal buftype=nowrite
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
132 let lastbuf = bufnr('$')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
133
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
134 augroup test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
135 autocmd!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
136 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
137 augroup END
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
138
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
139 normal! i1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
140 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
141 call feedkeys("\<CR>")
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
142
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
143 autocmd! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
144 augroup! test_autocmd_bufunload
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
145 bwipe! a.txt
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
146 endfunc
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
147
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
148 func Test_win_tab_autocmd()
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
149 let g:record = []
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 augroup testing
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
152 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
153 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
154 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
155 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
156 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
157 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
158 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
159 augroup END
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
160
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
161 split
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
162 tabnew
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
163 close
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
164 close
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
165
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
166 call assert_equal([
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
167 \ 'WinLeave', 'WinNew', 'WinEnter',
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
168 \ '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
169 \ 'WinLeave', 'TabLeave', 'TabClosed', 'WinEnter', 'TabEnter',
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
170 \ 'WinLeave', 'WinEnter'
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
171 \ ], g:record)
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
172
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
173 let g:record = []
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
174 tabnew somefile
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
175 tabnext
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
176 bwipe somefile
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
177
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
178 call assert_equal([
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
179 \ '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
180 \ 'WinLeave', 'TabLeave', 'WinEnter', 'TabEnter',
9599
42a8a81decdf commit https://github.com/vim/vim/commit/12c11d553053f5a9eae9eb3c518279b12fa928c2
Christian Brabandt <cb@256bit.org>
parents: 9595
diff changeset
181 \ 'TabClosed'
9595
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
182 \ ], g:record)
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
183
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
184 augroup testing
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
185 au!
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
186 augroup END
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
187 unlet g:record
0190d5de215f commit https://github.com/vim/vim/commit/c917da4b3e8801a255dbefea8e4ed19c1c716dd8
Christian Brabandt <cb@256bit.org>
parents: 9450
diff changeset
188 endfunc
9653
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
189
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
190 func s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
191 augroup vimBarTest
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
192 au BufReadCmd * echo 'hello'
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
193 augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
194 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
195 endfunc
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 func Test_early_bar()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
198 " 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
199 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
200 augroup vimBarTest | au! | augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
201 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
202
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
203 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
204 augroup vimBarTest| au!| augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
205 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
206
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
207 " 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
208 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
209 augroup vimBarTest| au!BufReadCmd| augroup END
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
210 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
211
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
212 " 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
213 call s:AddAnAutocmd()
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
214 au! vimBarTest|echo 'hello'
01c9630e80e0 commit https://github.com/vim/vim/commit/e99e84497b89e5f91df519790802770920ecf4fe
Christian Brabandt <cb@256bit.org>
parents: 9599
diff changeset
215 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
216 endfunc
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
217
10058
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
218 func RemoveGroup()
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
219 autocmd! StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
220 augroup! StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
221 endfunc
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
222
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
223 func Test_augroup_warning()
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
224 augroup TheWarning
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
225 au VimEnter * echo 'entering'
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
226 augroup END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
227 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
228 redir => res
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
229 augroup! TheWarning
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
230 redir END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
231 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
232 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
233
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
234 " 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
235 augroup Another
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
236 augroup END
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
237 call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
10141
b67088aae933 commit https://github.com/vim/vim/commit/aeac9006d5d14910f214f09df52c026a5936e737
Christian Brabandt <cb@256bit.org>
parents: 10114
diff changeset
238 augroup! Another
10058
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
239
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
240 " no warning for postpone aucmd delete
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
241 augroup StartOK
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
242 au VimEnter * call RemoveGroup()
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
243 augroup END
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
244 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
245 redir => res
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
246 doautocmd VimEnter
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
247 redir END
65e43481d7de commit https://github.com/vim/vim/commit/5c80908ced601be6db7554a147cdb0f98ac8daa1
Christian Brabandt <cb@256bit.org>
parents: 9682
diff changeset
248 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
249 au! VimEnter
9682
a98607bb756c commit https://github.com/vim/vim/commit/f2c4c391192cab6e923b1a418d4af09106fba25f
Christian Brabandt <cb@256bit.org>
parents: 9653
diff changeset
250 endfunc
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
251
12680
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
252 func Test_BufReadCmdHelp()
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
253 " This used to cause access to free memory
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
254 au BufReadCmd * e +h
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
255 help
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
256
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
257 helpclose
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
258 au! BufReadCmd
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
259 endfunc
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
260
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
261 func Test_BufReadCmdHelpJump()
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
262 " This used to cause access to free memory
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
263 au BufReadCmd * e +h{
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
264 help
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
265
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
266 helpclose
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
267 au! BufReadCmd
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
268 endfunc
429bf1b9292f patch 8.0.1218: writing to freed memory in autocmd
Christian Brabandt <cb@256bit.org>
parents: 12662
diff changeset
269
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
270 func Test_augroup_deleted()
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
271 " 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
272 augroup x
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
273 call assert_fails('augroup! x', 'E936:')
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
274 au VimEnter * echo
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
275 augroup end
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
276 augroup! x
10086
1de911ef1edf commit https://github.com/vim/vim/commit/de653f08805dde14424d417502a0480a6ad292f8
Christian Brabandt <cb@256bit.org>
parents: 10084
diff changeset
277 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
278 au! VimEnter
10084
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
279 endfunc
3e410e6e1986 commit https://github.com/vim/vim/commit/b62cc36a600e2e1e5a1d1d484fef89898c847c4c
Christian Brabandt <cb@256bit.org>
parents: 10058
diff changeset
280
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
281 " Tests for autocommands on :close command.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
282 " This used to be in test13.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
283 func Test_three_windows()
10242
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
284 " Clean up buffers, because in some cases this function fails.
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
285 call s:cleanup_buffers()
a369d97995ff commit https://github.com/vim/vim/commit/b3435b0a3a0967115658d0a8c0224a28969cfa02
Christian Brabandt <cb@256bit.org>
parents: 10151
diff changeset
286
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
287 " 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
288 " 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
289 " Do this twice, writing the file.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
290 e! Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
291 call setline(1, 'testje1')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
292 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
293 sp Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
294 call setline(1, 'testje2')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
295 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
296 sp Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
297 call setline(1, 'testje3')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
298 w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
299 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
300 au WinLeave Xtestje2 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
301 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
302 call assert_equal('Xtestje1', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
303
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
304 au WinLeave Xtestje1 bwipe Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
305 close
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
306 call assert_equal('Xtestje1', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
307
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
308 " 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
309 " will be the ATTENTION prompt.
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
310 e Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
311 au!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
312 au! BufUnload Xtestje1 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
313 call assert_fails('e Xtestje3', 'E937:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
314 call assert_equal('Xtestje3', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
315
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
316 e Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
317 sp Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
318 call assert_fails('e', 'E937:')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
319 call assert_equal('Xtestje2', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
320
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
321 " 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
322 " 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
323 au!
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
324 only
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
325 e Xanother
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
326 e Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
327 bwipe Xtestje2
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
328 bwipe Xtestje3
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
329 au BufWipeout Xtestje1 buf Xtestje1
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
330 bwipe
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
331 call assert_equal('Xanother', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
332
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
333 only
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
334 help
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
335 wincmd w
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
336 1quit
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
337 call assert_equal('Xanother', expand('%'))
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
338
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
339 au!
11197
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 10575
diff changeset
340 enew
7f355d8cd634 patch 8.0.0485: not all windows commands are tested
Christian Brabandt <cb@256bit.org>
parents: 10575
diff changeset
341 bwipe! Xtestje1
10106
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
342 call delete('Xtestje1')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
343 call delete('Xtestje2')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
344 call delete('Xtestje3')
58e6dd1d8be3 commit https://github.com/vim/vim/commit/e0ab94e7123ca7855f45919114d948ef2bc1e8c3
Christian Brabandt <cb@256bit.org>
parents: 10086
diff changeset
345 endfunc
10575
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
346
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
347 func Test_BufEnter()
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
348 au! BufEnter
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
349 au Bufenter * let val = val . '+'
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
350 let g:val = ''
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
351 split NewFile
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
352 call assert_equal('+', g:val)
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
353 bwipe!
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
354 call assert_equal('++', g:val)
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
355
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
356 " Also get BufEnter when editing a directory
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
357 call mkdir('Xdir')
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
358 split Xdir
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
359 call assert_equal('+++', g:val)
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
360
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
361 " On MS-Windows we can't edit the directory, make sure we wipe the right
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
362 " buffer.
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
363 bwipe! Xdir
10575
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
364
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
365 call delete('Xdir', 'd')
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
366 au! BufEnter
01a5f64a7a20 patch 8.0.0177: BufEnter autocommand not fired for a directory
Christian Brabandt <cb@256bit.org>
parents: 10242
diff changeset
367 endfunc
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
368
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
369 " Closing a window might cause an endless loop
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
370 " E814 for older Vims
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
371 func Test_autocmd_bufwipe_in_SessLoadPost()
12620
27a2fc398671 patch 8.0.1188: autocmd test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12616
diff changeset
372 edit Xtest
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
373 tabnew
12620
27a2fc398671 patch 8.0.1188: autocmd test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12616
diff changeset
374 file Xsomething
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
375 set noswapfile
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
376 mksession!
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
377
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
378 let content = ['set nocp noswapfile',
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
379 \ 'let v:swapchoice="e"',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
380 \ 'augroup test_autocmd_sessionload',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
381 \ 'autocmd!',
12620
27a2fc398671 patch 8.0.1188: autocmd test fails on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 12616
diff changeset
382 \ 'autocmd SessionLoadPost * exe bufnr("Xsomething") . "bw!"',
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
383 \ 'augroup END',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
384 \ '',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
385 \ 'func WriteErrors()',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
386 \ ' call writefile([execute("messages")], "Xerrors")',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
387 \ 'endfunc',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
388 \ 'au VimLeave * call WriteErrors()',
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
389 \ ]
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
390 call writefile(content, 'Xvimrc')
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
391 call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
392 let errors = join(readfile('Xerrors'))
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
393 call assert_match('E814', errors)
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
394
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
395 set swapfile
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
396 for file in ['Session.vim', 'Xvimrc', 'Xerrors']
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
397 call delete(file)
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
398 endfor
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
399 endfunc
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
400
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
401 " SEGV occurs in older versions.
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
402 func Test_autocmd_bufwipe_in_SessLoadPost2()
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
403 tabnew
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
404 set noswapfile
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
405 mksession!
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
406
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
407 let content = ['set nocp noswapfile',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
408 \ 'function! DeleteInactiveBufs()',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
409 \ ' tabfirst',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
410 \ ' let tabblist = []',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
411 \ ' for i in range(1, tabpagenr(''$''))',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
412 \ ' call extend(tabblist, tabpagebuflist(i))',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
413 \ ' endfor',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
414 \ ' for b in range(1, bufnr(''$''))',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
415 \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
416 \ ' exec ''bwipeout '' . b',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
417 \ ' endif',
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
418 \ ' endfor',
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
419 \ ' echomsg "SessionLoadPost DONE"',
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
420 \ 'endfunction',
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
421 \ 'au SessionLoadPost * call DeleteInactiveBufs()',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
422 \ '',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
423 \ 'func WriteErrors()',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
424 \ ' call writefile([execute("messages")], "Xerrors")',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
425 \ 'endfunc',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
426 \ 'au VimLeave * call WriteErrors()',
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
427 \ ]
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
428 call writefile(content, 'Xvimrc')
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
429 call system(v:progpath. ' -u Xvimrc --not-a-term --noplugins -S Session.vim -c cq')
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
430 let errors = join(readfile('Xerrors'))
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
431 " This probably only ever matches on unix.
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
432 call assert_notmatch('Caught deadly signal SEGV', errors)
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
433 call assert_match('SessionLoadPost DONE', errors)
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
434
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
435 set swapfile
11223
ac36e139510f patch 8.0.0498: two autocmd tests are skipped on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11201
diff changeset
436 for file in ['Session.vim', 'Xvimrc', 'Xerrors']
11199
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
437 call delete(file)
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
438 endfor
e08ead1d269f patch 8.0.0486: crash and endless loop when closing windows in autocmd
Christian Brabandt <cb@256bit.org>
parents: 11197
diff changeset
439 endfunc
11641
dbce7e03bf55 patch 8.0.0703: illegal memory access with empty :doau command
Christian Brabandt <cb@256bit.org>
parents: 11223
diff changeset
440
dbce7e03bf55 patch 8.0.0703: illegal memory access with empty :doau command
Christian Brabandt <cb@256bit.org>
parents: 11223
diff changeset
441 func Test_empty_doau()
dbce7e03bf55 patch 8.0.0703: illegal memory access with empty :doau command
Christian Brabandt <cb@256bit.org>
parents: 11223
diff changeset
442 doau \|
dbce7e03bf55 patch 8.0.0703: illegal memory access with empty :doau command
Christian Brabandt <cb@256bit.org>
parents: 11223
diff changeset
443 endfunc
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
444
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
445 func s:AutoCommandOptionSet(match)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
446 let item = remove(g:options, 0)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
447 let expected = printf("Option: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", item[0], item[1], item[2], item[3])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
448 let actual = printf("Option: <%s>, Oldval: <%s>, NewVal: <%s>, Scope: <%s>\n", a:match, v:option_old, v:option_new, v:option_type)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
449 let g:opt = [expected, actual]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
450 "call assert_equal(expected, actual)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
451 endfunc
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
452
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
453 func Test_OptionSet()
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
454 if !has("eval") || !has("autocmd") || !exists("+autochdir")
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
455 return
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
456 endif
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
457
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
458 badd test_autocmd.vim
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
459
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
460 call test_override('starting', 1)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
461 set nocp
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
462 au OptionSet * :call s:AutoCommandOptionSet(expand("<amatch>"))
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
463
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
464 " 1: Setting number option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
465 let g:options=[['number', 0, 1, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
466 set nu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
467 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
468 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
469
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
470 " 2: Setting local number option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
471 let g:options=[['number', 1, 0, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
472 setlocal nonu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
473 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
474 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
475
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
476 " 3: Setting global number option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
477 let g:options=[['number', 1, 0, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
478 setglobal nonu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
479 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
480 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
481
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
482 " 4: Setting local autoindent option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
483 let g:options=[['autoindent', 0, 1, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
484 setlocal ai
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
485 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
486 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
487
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
488 " 5: Setting global autoindent option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
489 let g:options=[['autoindent', 0, 1, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
490 setglobal ai
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
491 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
492 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
493
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
494 " 6: Setting global autoindent option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
495 let g:options=[['autoindent', 1, 0, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
496 set ai!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
497 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
498 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
499
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
500 " Should not print anything, use :noa
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
501 " 7: don't trigger OptionSet"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
502 let g:options=[['invalid', 1, 1, 'invalid']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
503 noa set nonu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
504 call assert_equal([['invalid', 1, 1, 'invalid']], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
505 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
506
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
507 " 8: Setting several global list and number option"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
508 let g:options=[['list', 0, 1, 'global'], ['number', 0, 1, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
509 set list nu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
510 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
511 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
512
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
513 " 9: don't trigger OptionSet"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
514 let g:options=[['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
515 noa set nolist nonu
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
516 call assert_equal([['invalid', 1, 1, 'invalid'], ['invalid', 1, 1, 'invalid']], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
517 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
518
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
519 " 10: Setting global acd"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
520 let g:options=[['autochdir', 0, 1, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
521 setlocal acd
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
522 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
523 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
524
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
525 " 11: Setting global autoread (also sets local value)"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
526 let g:options=[['autoread', 0, 1, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
527 set ar
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
528 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
529 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
530
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
531 " 12: Setting local autoread"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
532 let g:options=[['autoread', 1, 1, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
533 setlocal ar
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
534 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
535 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
536
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
537 " 13: Setting global autoread"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
538 let g:options=[['autoread', 1, 0, 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
539 setglobal invar
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
540 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
541 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
542
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
543 " 14: Setting option backspace through :let"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
544 let g:options=[['backspace', '', 'eol,indent,start', 'global']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
545 let &bs="eol,indent,start"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
546 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
547 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
548
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
549 " 15: Setting option backspace through setbufvar()"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
550 let g:options=[['backup', 0, 1, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
551 " try twice, first time, shouldn't trigger because option name is invalid,
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
552 " second time, it should trigger
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
553 let bnum = bufnr('%')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
554 call assert_fails("call setbufvar(bnum, '&l:bk', 1)", "E355")
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
555 " should trigger, use correct option name
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
556 call setbufvar(bnum, '&backup', 1)
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
557 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
558 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
559
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
560 " 16: Setting number option using setwinvar"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
561 let g:options=[['number', 0, 1, 'local']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
562 call setwinvar(0, '&number', 1)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
563 call assert_equal([], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
564 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
565
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
566 " 17: Setting key option, shouldn't trigger"
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
567 let g:options=[['key', 'invalid', 'invalid1', 'invalid']]
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
568 setlocal key=blah
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
569 setlocal key=
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
570 call assert_equal([['key', 'invalid', 'invalid1', 'invalid']], g:options)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
571 call assert_equal(g:opt[0], g:opt[1])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
572
12188
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
573 " 18: Setting string option"
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
574 let oldval = &tags
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
575 let g:options=[['tags', oldval, 'tagpath', 'global']]
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
576 set tags=tagpath
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
577 call assert_equal([], g:options)
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
578 call assert_equal(g:opt[0], g:opt[1])
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
579
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
580 " 1l: Resetting string option"
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
581 let g:options=[['tags', 'tagpath', oldval, 'global']]
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
582 set tags&
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
583 call assert_equal([], g:options)
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
584 call assert_equal(g:opt[0], g:opt[1])
d2e367d9de1f patch 8.0.0974: resetting a string option does not trigger OptionSet
Christian Brabandt <cb@256bit.org>
parents: 11961
diff changeset
585
11707
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
586 " Cleanup
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
587 au! OptionSet
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
588 for opt in ['nu', 'ai', 'acd', 'ar', 'bs', 'backup', 'cul', 'cp']
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
589 exe printf(":set %s&vi", opt)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
590 endfor
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
591 call test_override('starting', 0)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
592 delfunc! AutoCommandOptionSet
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
593 endfunc
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
594
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
595 func Test_OptionSet_diffmode()
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
596 call test_override('starting', 1)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
597 " 18: Changing an option when enetering diff mode
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
598 new
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
599 au OptionSet diff :let &l:cul=v:option_new
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
600
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
601 call setline(1, ['buffer 1', 'line2', 'line3', 'line4'])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
602 call assert_equal(0, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
603 diffthis
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
604 call assert_equal(1, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
605
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
606 vnew
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
607 call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4'])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
608 call assert_equal(0, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
609 diffthis
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
610 call assert_equal(1, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
611
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
612 diffoff
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
613 call assert_equal(0, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
614 call assert_equal(1, getwinvar(2, '&l:cul'))
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
615 bw!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
616
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
617 call assert_equal(1, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
618 diffoff!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
619 call assert_equal(0, &l:cul)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
620 call assert_equal(0, getwinvar(1, '&l:cul'))
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
621 bw!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
622
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
623 " Cleanup
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
624 au! OptionSet
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
625 call test_override('starting', 0)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
626 endfunc
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
627
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
628 func Test_OptionSet_diffmode_close()
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
629 call test_override('starting', 1)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
630 " 19: Try to close the current window when entering diff mode
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
631 " should not segfault
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
632 new
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
633 au OptionSet diff close
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
634
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
635 call setline(1, ['buffer 1', 'line2', 'line3', 'line4'])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
636 call assert_fails(':diffthis', 'E788')
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
637 call assert_equal(1, &diff)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
638 vnew
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
639 call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4'])
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
640 call assert_fails(':diffthis', 'E788')
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
641 call assert_equal(1, &diff)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
642 bw!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
643 call assert_fails(':diffoff!', 'E788')
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
644 bw!
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
645
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
646 " Cleanup
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
647 au! OptionSet
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
648 call test_override('starting', 0)
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
649 "delfunc! AutoCommandOptionSet
1395a3b6978d patch 8.0.0736: OptionSet not triggered when entering diff mode
Christian Brabandt <cb@256bit.org>
parents: 11641
diff changeset
650 endfunc
11961
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
651
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
652 " Test for Bufleave autocommand that deletes the buffer we are about to edit.
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
653 func Test_BufleaveWithDelete()
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
654 new | edit Xfile1
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
655
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
656 augroup test_bufleavewithdelete
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
657 autocmd!
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
658 autocmd BufLeave Xfile1 bwipe Xfile2
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
659 augroup END
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
660
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
661 call assert_fails('edit Xfile2', 'E143:')
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
662 call assert_equal('Xfile1', bufname('%'))
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
663
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
664 autocmd! test_bufleavewithdelete BufLeave Xfile1
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
665 augroup! test_bufleavewithdelete
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
666
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
667 new
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
668 bwipe! Xfile1
0240e7e3d736 patch 8.0.0861: still many old style tests
Christian Brabandt <cb@256bit.org>
parents: 11707
diff changeset
669 endfunc
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
670
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
671 " Test for autocommand that changes the buffer list, when doing ":ball".
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
672 func Test_Acmd_BufAll()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
673 enew!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
674 %bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
675 call writefile(['Test file Xxx1'], 'Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
676 call writefile(['Test file Xxx2'], 'Xxx2')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
677 call writefile(['Test file Xxx3'], 'Xxx3')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
678
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
679 " Add three files to the buffer list
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
680 split Xxx1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
681 close
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
682 split Xxx2
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
683 close
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
684 split Xxx3
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
685 close
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
686
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
687 " Wipe the buffer when the buffer is opened
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
688 au BufReadPost Xxx2 bwipe
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
689
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
690 call append(0, 'Test file Xxx4')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
691 ball
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
692
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
693 call assert_equal(2, winnr('$'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
694 call assert_equal('Xxx1', bufname(winbufnr(winnr('$'))))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
695 wincmd t
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
696
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
697 au! BufReadPost
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
698 %bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
699 call delete('Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
700 call delete('Xxx2')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
701 call delete('Xxx3')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
702 enew! | only
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
703 endfunc
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
704
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
705 " Test for autocommand that changes current buffer on BufEnter event.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
706 " Check if modelines are interpreted for the correct buffer.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
707 func Test_Acmd_BufEnter()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
708 %bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
709 call writefile(['start of test file Xxx1',
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
710 \ "\<Tab>this is a test",
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
711 \ 'end of test file Xxx1'], 'Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
712 call writefile(['start of test file Xxx2',
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
713 \ 'vim: set noai :',
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
714 \ "\<Tab>this is a test",
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
715 \ 'end of test file Xxx2'], 'Xxx2')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
716
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
717 au BufEnter Xxx2 brew
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
718 set ai modeline modelines=3
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
719 edit Xxx1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
720 " edit Xxx2, autocmd will do :brew
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
721 edit Xxx2
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
722 exe "normal G?this is a\<CR>"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
723 " Append text with autoindent to this file
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
724 normal othis should be auto-indented
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
725 call assert_equal("\<Tab>this should be auto-indented", getline('.'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
726 call assert_equal(3, line('.'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
727 " Remove autocmd and edit Xxx2 again
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
728 au! BufEnter Xxx2
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
729 buf! Xxx2
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
730 exe "normal G?this is a\<CR>"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
731 " append text without autoindent to Xxx
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
732 normal othis should be in column 1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
733 call assert_equal("this should be in column 1", getline('.'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
734 call assert_equal(4, line('.'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
735
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
736 %bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
737 call delete('Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
738 call delete('Xxx2')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
739 set ai&vim modeline&vim modelines&vim
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
740 endfunc
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
741
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
742 " Test for issue #57
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
743 " do not move cursor on <c-o> when autoindent is set
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
744 func Test_ai_CTRL_O()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
745 enew!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
746 set ai
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
747 let save_fo = &fo
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
748 set fo+=r
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
749 exe "normal o# abcdef\<Esc>2hi\<CR>\<C-O>d0\<Esc>"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
750 exe "normal o# abcdef\<Esc>2hi\<C-O>d0\<Esc>"
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
751 call assert_equal(['# abc', 'def', 'def'], getline(2, 4))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
752
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
753 set ai&vim
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
754 let &fo = save_fo
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
755 enew!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
756 endfunc
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
757
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
758 " Test for autocommand that deletes the current buffer on BufLeave event.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
759 " Also test deleting the last buffer, should give a new, empty buffer.
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
760 func Test_BufLeave_Wipe()
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
761 %bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
762 let content = ['start of test file Xxx',
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
763 \ 'this is a test',
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
764 \ 'end of test file Xxx']
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
765 call writefile(content, 'Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
766 call writefile(content, 'Xxx2')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
767
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
768 au BufLeave Xxx2 bwipe
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
769 edit Xxx1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
770 split Xxx2
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
771 " delete buffer Xxx2, we should be back to Xxx1
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
772 bwipe
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
773 call assert_equal('Xxx1', bufname('%'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
774 call assert_equal(1, winnr('$'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
775
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
776 " Create an alternate buffer
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
777 %write! test.out
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
778 call assert_equal('test.out', bufname('#'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
779 " delete alternate buffer
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
780 bwipe test.out
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
781 call assert_equal('Xxx1', bufname('%'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
782 call assert_equal('', bufname('#'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
783
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
784 au BufLeave Xxx1 bwipe
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
785 " delete current buffer, get an empty one
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
786 bwipe!
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
787 call assert_equal(1, line('$'))
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
788 call assert_equal('', bufname('%'))
12630
560adb3eed8b patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Christian Brabandt <cb@256bit.org>
parents: 12620
diff changeset
789 let g:bufinfo = getbufinfo()
560adb3eed8b patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Christian Brabandt <cb@256bit.org>
parents: 12620
diff changeset
790 call assert_equal(1, len(g:bufinfo))
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
791
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
792 call delete('Xxx1')
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
793 call delete('Xxx2')
12662
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
794 call delete('test.out')
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
795 %bwipe
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
796 au! BufLeave
12630
560adb3eed8b patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Christian Brabandt <cb@256bit.org>
parents: 12620
diff changeset
797
560adb3eed8b patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Christian Brabandt <cb@256bit.org>
parents: 12620
diff changeset
798 " check that bufinfo doesn't contain a pointer to freed memory
560adb3eed8b patch 8.0.1193: crash when wiping out a buffer after using getbufinfo()
Christian Brabandt <cb@256bit.org>
parents: 12620
diff changeset
799 call test_garbagecollect_now()
12616
4767939d10cc patch 8.0.1186: still quite a few old style tests
Christian Brabandt <cb@256bit.org>
parents: 12188
diff changeset
800 endfunc
12652
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
801
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
802 func Test_QuitPre()
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
803 edit Xfoo
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
804 let winid = win_getid(winnr())
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
805 split Xbar
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
806 au! QuitPre * let g:afile = expand('<afile>')
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
807 " Close the other window, <afile> should be correct.
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
808 exe win_id2win(winid) . 'q'
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
809 call assert_equal('Xfoo', g:afile)
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
810
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
811 unlet g:afile
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
812 bwipe Xfoo
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
813 bwipe Xbar
272ecbaf1b4f patch 8.0.1204: a QuitPre autocommand may get the wrong file name
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
814 endfunc
12656
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
815
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
816 func Test_Cmdline()
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
817 au! CmdlineEnter : let g:entered = expand('<afile>')
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
818 au! CmdlineLeave : let g:left = expand('<afile>')
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
819 let g:entered = 0
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
820 let g:left = 0
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
821 call feedkeys(":echo 'hello'\<CR>", 'xt')
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
822 call assert_equal(':', g:entered)
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
823 call assert_equal(':', g:left)
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
824 au! CmdlineEnter
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
825 au! CmdlineLeave
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
826
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
827 au! CmdlineEnter / let g:entered = expand('<afile>')
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
828 au! CmdlineLeave / let g:left = expand('<afile>')
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
829 let g:entered = 0
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
830 let g:left = 0
12662
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
831 new
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
832 call setline(1, 'hello')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
833 call feedkeys("/hello\<CR>", 'xt')
12656
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
834 call assert_equal('/', g:entered)
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
835 call assert_equal('/', g:left)
12662
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
836 bwipe!
12656
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
837 au! CmdlineEnter
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
838 au! CmdlineLeave
0a9dacb8826a patch 8.0.1206: no autocmd for entering or leaving the command line
Christian Brabandt <cb@256bit.org>
parents: 12652
diff changeset
839 endfunc
12662
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
840
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
841 " Test for BufWritePre autocommand that deletes or unloads the buffer.
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
842 func Test_BufWritePre()
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
843 %bwipe
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
844 au BufWritePre Xxx1 bunload
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
845 au BufWritePre Xxx2 bwipe
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
846
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
847 call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
848 call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
849
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
850 edit Xtest
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
851 e! Xxx2
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
852 bdel Xtest
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
853 e Xxx1
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
854 " write it, will unload it and give an error msg
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
855 call assert_fails('w', 'E203')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
856 call assert_equal('Xxx2', bufname('%'))
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
857 edit Xtest
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
858 e! Xxx2
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
859 bwipe Xtest
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
860 " write it, will delete the buffer and give an error msg
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
861 call assert_fails('w', 'E203')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
862 call assert_equal('Xxx1', bufname('%'))
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
863 au! BufWritePre
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
864 call delete('Xxx1')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
865 call delete('Xxx2')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
866 endfunc
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
867
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
868 " Test for BufUnload autocommand that unloads all the other buffers
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
869 func Test_bufunload_all()
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
870 call writefile(['Test file Xxx1'], 'Xxx1')"
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
871 call writefile(['Test file Xxx2'], 'Xxx2')"
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
872
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
873 let content = [
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
874 \ "func UnloadAllBufs()",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
875 \ " let i = 1",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
876 \ " while i <= bufnr('$')",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
877 \ " if i != bufnr('%') && bufloaded(i)",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
878 \ " exe i . 'bunload'",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
879 \ " endif",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
880 \ " let i += 1",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
881 \ " endwhile",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
882 \ "endfunc",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
883 \ "au BufUnload * call UnloadAllBufs()",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
884 \ "au VimLeave * call writefile(['Test Finished'], 'Xout')",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
885 \ "edit Xxx1",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
886 \ "split Xxx2",
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
887 \ "q"]
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
888 call writefile(content, 'Xtest')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
889
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
890 call delete('Xout')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
891 call system(v:progpath. ' --clean -N --not-a-term -S Xtest')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
892 call assert_true(filereadable('Xout'))
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
893
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
894 call delete('Xxx1')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
895 call delete('Xxx2')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
896 call delete('Xtest')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
897 call delete('Xout')
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
898 endfunc
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
899
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
900 " Some tests for buffer-local autocommands
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
901 func Test_buflocal_autocmd()
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
902 let g:bname = ''
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
903 edit xx
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
904 au BufLeave <buffer> let g:bname = expand("%")
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
905 " here, autocommand for xx should trigger.
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
906 " but autocommand shall not apply to buffer named <buffer>.
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
907 edit somefile
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
908 call assert_equal('xx', g:bname)
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
909 let g:bname = ''
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
910 " here, autocommand shall be auto-deleted
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
911 bwipe xx
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
912 " autocmd should not trigger
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
913 edit xx
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
914 call assert_equal('', g:bname)
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
915 " autocmd should not trigger
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
916 edit somefile
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
917 call assert_equal('', g:bname)
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
918 enew
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
919 unlet g:bname
15f0f9f16cd9 patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12656
diff changeset
920 endfunc