annotate src/testdir/test_mapping.vim @ 30582:72245f9c9405 v9.0.0626

patch 9.0.0626: too many delete() calls in tests Commit: https://github.com/vim/vim/commit/b152b6a40f729ed81a25d2fa541a4e73e201bec4 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 29 21:37:33 2022 +0100 patch 9.0.0626: too many delete() calls in tests Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
author Bram Moolenaar <Bram@vim.org>
date Thu, 29 Sep 2022 22:45:04 +0200
parents 539fb427124d
children ae3970cc28cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for mappings and abbreviations
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
3 source shared.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17249
diff changeset
4 source check.vim
18689
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
5 source screendump.vim
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
6 source term_util.vim
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27241
diff changeset
7 import './vim9.vim' as v9
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
8
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 func Test_abbreviation()
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " abbreviation with 0x80 should work
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 inoreab чкпр vim
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call feedkeys("Goчкпр \<Esc>", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_equal('vim ', getline('$'))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 iunab чкпр
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17
16389
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
18 func Test_abclear()
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
19 abbrev foo foobar
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
20 iabbrev fooi foobari
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
21 cabbrev fooc foobarc
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
22 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
23 \ .. "c fooc foobarc\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
24 \ .. "i fooi foobari\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
25 \ .. "! foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
26
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
27 iabclear
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
28 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
29 \ .. "c fooc foobarc\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
30 \ .. "c foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
31 abbrev foo foobar
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
32 iabbrev fooi foobari
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
33
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
34 cabclear
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
35 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
36 \ .. "i fooi foobari\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
37 \ .. "i foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
38 abbrev foo foobar
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
39 cabbrev fooc foobarc
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
40
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
41 abclear
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
42 call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
19407
2f4be7ca1b1b patch 8.2.0261: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
43 call assert_fails('%abclear', 'E481:')
16389
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
44 endfunc
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
45
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
46 func Test_abclear_buffer()
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
47 abbrev foo foobar
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
48 new X1
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
49 abbrev <buffer> foo1 foobar1
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
50 new X2
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
51 abbrev <buffer> foo2 foobar2
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
52
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
53 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
54 \ .. "! foo2 @foobar2\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
55 \ .. "! foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
56
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
57 abclear <buffer>
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
58 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
59 \ .. "! foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
60
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
61 b X1
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
62 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
63 \ .. "! foo1 @foobar1\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
64 \ .. "! foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
65 abclear <buffer>
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
66 call assert_equal("\n\n"
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
67 \ .. "! foo foobar", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
68
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
69 abclear
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
70 call assert_equal("\n\nNo abbreviation found", execute('abbrev'))
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
71
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
72 %bwipe
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
73 endfunc
fb7cf38a1c7a patch 8.1.1199: no test for :abclear
Bram Moolenaar <Bram@vim.org>
parents: 16101
diff changeset
74
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 func Test_map_ctrl_c_insert()
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 " mapping of ctrl-c in Insert mode
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 set cpo-=< cpo-=k
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 inoremap <c-c> <ctrl-c>
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 cnoremap <c-c> dummy
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 cunmap <c-c>
20627
8bce783af0cb patch 8.2.0867: using {xxx} for encoding a modifier is not nice
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
81 call feedkeys("GoTEST2: CTRL-C |\<*C-C>A|\<Esc>", "xt")
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 call assert_equal('TEST2: CTRL-C |<ctrl-c>A|', getline('$'))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 unmap! <c-c>
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 func Test_map_ctrl_c_visual()
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 " mapping of ctrl-c in Visual mode
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 vnoremap <c-c> :<C-u>$put ='vmap works'
20627
8bce783af0cb patch 8.2.0867: using {xxx} for encoding a modifier is not nice
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
90 call feedkeys("GV\<*C-C>\<CR>", "xt")
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 call assert_equal('vmap works', getline('$'))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 vunmap <c-c>
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 func Test_map_langmap()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20627
diff changeset
97 CheckFeature langmap
9925
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
98
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
99 " check langmap applies in normal mode
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
100 set langmap=+- nolangremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
101 new
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
102 call setline(1, ['a', 'b', 'c'])
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
103 2
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
104 call assert_equal('b', getline('.'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
105 call feedkeys("+", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
106 call assert_equal('a', getline('.'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
107
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
108 " check no remapping
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
109 map x +
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
110 2
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
111 call feedkeys("x", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
112 call assert_equal('c', getline('.'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
113
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
114 " check with remapping
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
115 set langremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
116 2
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
117 call feedkeys("x", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
118 call assert_equal('a', getline('.'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
119
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
120 unmap x
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
121 bwipe!
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
122
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
123 " 'langnoremap' follows 'langremap' and vise versa
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
124 set langremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
125 set langnoremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
126 call assert_equal(0, &langremap)
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
127 set langremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
128 call assert_equal(0, &langnoremap)
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
129 set nolangremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
130 call assert_equal(1, &langnoremap)
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
131
10070
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
132 " check default values
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
133 set langnoremap&
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
134 call assert_equal(0, &langnoremap)
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
135 call assert_equal(1, &langremap)
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
136 set langremap&
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
137 call assert_equal(0, &langnoremap)
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
138 call assert_equal(1, &langremap)
09c7df6f8dd3 commit https://github.com/vim/vim/commit/da9ce2cde11ddd0e16cdfbab6d4ac4e8110218e1
Christian Brabandt <cb@256bit.org>
parents: 9925
diff changeset
139
9925
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
140 " langmap should not apply in insert mode, 'langremap' doesn't matter
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
141 set langmap=+{ nolangremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
142 call feedkeys("Go+\<Esc>", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
143 call assert_equal('+', getline('$'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
144 set langmap=+{ langremap
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 call feedkeys("Go+\<Esc>", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 call assert_equal('+', getline('$'))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147
9925
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
148 " langmap used for register name in insert mode.
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
149 call setreg('a', 'aaaa')
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
150 call setreg('b', 'bbbb')
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
151 call setreg('c', 'cccc')
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
152 set langmap=ab langremap
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
153 call feedkeys("Go\<C-R>a\<Esc>", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
154 call assert_equal('bbbb', getline('$'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
155 call feedkeys("Go\<C-R>\<C-R>a\<Esc>", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
156 call assert_equal('bbbb', getline('$'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
157 " mapping does not apply
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
158 imap c a
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
159 call feedkeys("Go\<C-R>c\<Esc>", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
160 call assert_equal('cccc', getline('$'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
161 imap a c
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
162 call feedkeys("Go\<C-R>a\<Esc>", "xt")
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
163 call assert_equal('bbbb', getline('$'))
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
164
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
165 " langmap should not apply in Command-line mode
3fba3e8326a7 commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Christian Brabandt <cb@256bit.org>
parents: 9869
diff changeset
166 set langmap=+{ nolangremap
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 call assert_equal('+', getline('$'))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10070
diff changeset
170 iunmap a
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10070
diff changeset
171 iunmap c
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 func Test_map_feedkeys()
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 " issue #212 (feedkeys insert mapping at current position)
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 nnoremap . :call feedkeys(".", "in")<cr>
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 call setline('$', ['a b c d', 'a b c d'])
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 $-1
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 call feedkeys("0qqdw.ifoo\<Esc>qj0@q\<Esc>", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$')))
10787
09926123316b patch 8.0.0283: mode() does not indicate Insert mode completion
Christian Brabandt <cb@256bit.org>
parents: 10070
diff changeset
182 nunmap .
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 func Test_map_cursor()
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 " <c-g>U<cursor> works only within a single line
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 imapclear
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 imap ( ()<c-g>U<left>
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 call feedkeys("G2o\<Esc>ki\<CR>Test1: text with a (here some more text\<Esc>k.", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 call assert_equal('Test1: text with a (here some more text)', getline(line('$') - 2))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 call assert_equal('Test1: text with a (here some more text)', getline(line('$') - 1))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194 " test undo
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 call feedkeys("G2o\<Esc>ki\<CR>Test2: text wit a (here some more text [und undo]\<C-G>u\<Esc>k.u", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 call assert_equal('', getline(line('$') - 2))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 call assert_equal('Test2: text wit a (here some more text [und undo])', getline(line('$') - 1))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 imapclear
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 endfunc
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201
16101
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
202 func Test_map_cursor_ctrl_gU()
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
203 " <c-g>U<cursor> works only within a single line
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
204 nnoremap c<* *Ncgn<C-r>"<C-G>U<S-Left>
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
205 call setline(1, ['foo', 'foobar', '', 'foo'])
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
206 call cursor(1,2)
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
207 call feedkeys("c<*PREFIX\<esc>.", 'xt')
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
208 call assert_equal(['PREFIXfoo', 'foobar', '', 'PREFIXfoo'], getline(1,'$'))
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
209 " break undo manually
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
210 set ul=1000
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
211 exe ":norm! uu"
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
212 call assert_equal(['foo', 'foobar', '', 'foo'], getline(1,'$'))
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
213
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
214 " Test that it does not work if the cursor moves to the previous line
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
215 " 2 times <S-Left> move to the previous line
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
216 nnoremap c<* *Ncgn<C-r>"<C-G>U<S-Left><C-G>U<S-Left>
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
217 call setline(1, ['', ' foo', 'foobar', '', 'foo'])
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
218 call cursor(2,3)
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
219 call feedkeys("c<*PREFIX\<esc>.", 'xt')
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
220 call assert_equal(['PREFIXPREFIX', ' foo', 'foobar', '', 'foo'], getline(1,'$'))
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
221 nmapclear
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
222 endfunc
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
223
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
224
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 " This isn't actually testing a mapping, but similar use of CTRL-G U as above.
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 func Test_break_undo()
16101
5c5d211bd5a8 patch 8.1.1055: CTRL-G U in Insert mode doesn't work for shift-Left
Bram Moolenaar <Bram@vim.org>
parents: 15687
diff changeset
227 set whichwrap=<,>,[,]
9867
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 call feedkeys("G4o2k", "xt")
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 exe ":norm! iTest3: text with a (parenthesis here\<C-G>U\<Right>new line here\<esc>\<up>\<up>."
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 call assert_equal('new line here', getline(line('$') - 3))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 call assert_equal('Test3: text with a (parenthesis here', getline(line('$') - 2))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 call assert_equal('new line here', getline(line('$') - 1))
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 set nomodified
86f73f026a9a commit https://github.com/vim/vim/commit/2d1a248762f069e470acde389ff4686a45d2f817
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 endfunc
9869
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
235
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
236 func Test_map_meta_quotes()
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
237 imap <M-"> foo
20627
8bce783af0cb patch 8.2.0867: using {xxx} for encoding a modifier is not nice
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
238 call feedkeys("Go-\<*M-\">-\<Esc>", "xt")
9869
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
239 call assert_equal("-foo-", getline('$'))
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
240 set nomodified
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
241 iunmap <M-">
989d44d35a66 commit https://github.com/vim/vim/commit/35a4cfa200917dd171b1fff3cd5b6cee9add673d
Christian Brabandt <cb@256bit.org>
parents: 9867
diff changeset
242 endfunc
11295
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
243
17720
844f470532b6 patch 8.1.1857: cannot use modifier with multi-byte character
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
244 func Test_map_meta_multibyte()
844f470532b6 patch 8.1.1857: cannot use modifier with multi-byte character
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
245 imap <M-á> foo
17722
bf807c68ac80 patch 8.1.1858: test for multi-byte mapping fails on some systems
Bram Moolenaar <Bram@vim.org>
parents: 17720
diff changeset
246 call assert_match('i <M-á>\s*foo', execute('imap'))
17720
844f470532b6 patch 8.1.1857: cannot use modifier with multi-byte character
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
247 iunmap <M-á>
844f470532b6 patch 8.1.1857: cannot use modifier with multi-byte character
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
248 endfunc
844f470532b6 patch 8.1.1857: cannot use modifier with multi-byte character
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
249
11295
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
250 func Test_abbr_after_line_join()
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
251 new
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
252 abbr foo bar
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
253 set backspace=indent,eol,start
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
254 exe "normal o\<BS>foo "
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
255 call assert_equal("bar ", getline(1))
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
256 bwipe!
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
257 unabbr foo
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
258 set backspace&
d772bf077b3f patch 8.0.0533: abbreviation doesn't work after backspacing newline
Christian Brabandt <cb@256bit.org>
parents: 10787
diff changeset
259 endfunc
11403
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
260
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
261 func Test_map_timeout()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20627
diff changeset
262 CheckFeature timers
11403
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
263 nnoremap aaaa :let got_aaaa = 1<CR>
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
264 nnoremap bb :let got_bb = 1<CR>
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
265 nmap b aaa
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
266 new
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
267 func ExitInsert(timer)
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
268 let g:line = getline(1)
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
269 call feedkeys("\<Esc>", "t")
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
270 endfunc
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
271 set timeout timeoutlen=200
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
272 let timer = timer_start(300, 'ExitInsert')
11403
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
273 " After the 'b' Vim waits for another character to see if it matches 'bb'.
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
274 " When it times out it is expanded to "aaa", but there is no wait for
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
275 " "aaaa". Can't check that reliably though.
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
276 call feedkeys("b", "xt!")
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
277 call assert_equal("aa", g:line)
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
278 call assert_false(exists('got_aaa'))
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
279 call assert_false(exists('got_bb'))
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
280
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
281 bwipe!
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
282 nunmap aaaa
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
283 nunmap bb
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
284 nunmap b
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
285 set timeoutlen&
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
286 delfunc ExitInsert
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
287 call timer_stop(timer)
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
288 endfunc
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
289
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
290 func Test_map_timeout_with_timer_interrupt()
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20627
diff changeset
291 CheckFeature job
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20627
diff changeset
292 CheckFeature timers
25969
a5a772dace5b patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
293 let g:test_is_flaky = 1
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
294
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
295 " Confirm the timer invoked in exit_cb of the job doesn't disturb mapped key
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
296 " sequence.
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
297 new
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
298 let g:val = 0
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
299 nnoremap \12 :let g:val = 1<CR>
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
300 nnoremap \123 :let g:val = 2<CR>
17726
586558396b7e patch 8.1.1860: map timeout test is flaky
Bram Moolenaar <Bram@vim.org>
parents: 17722
diff changeset
301 set timeout timeoutlen=200
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
302
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
303 func ExitCb(job, status)
15687
cb501b3c9fb5 patch 8.1.0851: feedkeys() with "L" does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 15659
diff changeset
304 let g:timer = timer_start(1, {-> feedkeys("3\<Esc>", 't')})
15659
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
305 endfunc
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
306
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
307 call job_start([&shell, &shellcmdflag, 'echo'], {'exit_cb': 'ExitCb'})
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
308 call feedkeys('\12', 'xt!')
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
309 call assert_equal(2, g:val)
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
310
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
311 bwipe!
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
312 nunmap \12
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
313 nunmap \123
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
314 set timeoutlen&
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
315 call WaitFor({-> exists('g:timer')})
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
316 call timer_stop(g:timer)
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
317 unlet g:timer
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
318 unlet g:val
8513d9864f7e patch 8.1.0837: timer interrupting cursorhold and mapping not tested
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
319 delfunc ExitCb
11403
74a40efb39ea patch 8.0.0586: no test for mapping timing out
Christian Brabandt <cb@256bit.org>
parents: 11295
diff changeset
320 endfunc
13788
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
321
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
322 func Test_abbreviation_CR()
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
323 new
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
324 func Eatchar(pat)
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
325 let c = nr2char(getchar(0))
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
326 return (c =~ a:pat) ? '' : c
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
327 endfunc
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
328 iabbrev <buffer><silent> ~~7 <c-r>=repeat('~', 7)<CR><c-r>=Eatchar('\s')<cr>
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
329 call feedkeys("GA~~7 \<esc>", 'xt')
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
330 call assert_equal('~~~~~~~', getline('$'))
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
331 %d
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
332 call feedkeys("GA~~7\<cr>\<esc>", 'xt')
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
333 call assert_equal(['~~~~~~~', ''], getline(1,'$'))
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
334 delfunc Eatchar
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
335 bw!
a27d380b257f patch 8.0.1766: expanding abbreviation doesn't work
Christian Brabandt <cb@256bit.org>
parents: 11403
diff changeset
336 endfunc
13933
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
337
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
338 func Test_cabbr_visual_mode()
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
339 cabbr s su
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
340 call feedkeys(":s \<c-B>\"\<CR>", 'itx')
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
341 call assert_equal('"su ', getreg(':'))
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
342 call feedkeys(":'<,'>s \<c-B>\"\<CR>", 'itx')
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
343 let expected = '"'. "'<,'>su "
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
344 call assert_equal(expected, getreg(':'))
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
345 call feedkeys(": '<,'>s \<c-B>\"\<CR>", 'itx')
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
346 let expected = '" '. "'<,'>su "
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
347 call assert_equal(expected, getreg(':'))
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
348 call feedkeys(":'a,'bs \<c-B>\"\<CR>", 'itx')
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
349 let expected = '"'. "'a,'bsu "
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
350 call assert_equal(expected, getreg(':'))
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
351 cunabbr s
bea665293ea0 patch 8.0.1837: one character cmdline abbreviation not triggered after '<,'>
Christian Brabandt <cb@256bit.org>
parents: 13788
diff changeset
352 endfunc
15279
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
353
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
354 func Test_motionforce_omap()
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
355 func GetCommand()
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
356 let g:m=mode(1)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
357 let [g:lnum1, g:col1] = searchpos('-', 'Wb')
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
358 if g:lnum1 == 0
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
359 return "\<Esc>"
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
360 endif
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
361 let [g:lnum2, g:col2] = searchpos('-', 'W')
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
362 if g:lnum2 == 0
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
363 return "\<Esc>"
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
364 endif
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
365 return ":call Select()\<CR>"
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
366 endfunc
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
367 func Select()
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
368 call cursor([g:lnum1, g:col1])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
369 exe "normal! 1 ". (strlen(g:m) == 2 ? 'v' : g:m[2])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
370 call cursor([g:lnum2, g:col2])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
371 execute "normal! \<BS>"
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
372 endfunc
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
373 new
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
374 onoremap <buffer><expr> i- GetCommand()
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
375 " 1) default omap mapping
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
376 %d_
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
377 call setline(1, ['aaa - bbb', 'x', 'ddd - eee'])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
378 call cursor(2, 1)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
379 norm di-
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
380 call assert_equal('no', g:m)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
381 call assert_equal(['aaa -- eee'], getline(1, '$'))
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
382 " 2) forced characterwise operation
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
383 %d_
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
384 call setline(1, ['aaa - bbb', 'x', 'ddd - eee'])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
385 call cursor(2, 1)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
386 norm dvi-
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
387 call assert_equal('nov', g:m)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
388 call assert_equal(['aaa -- eee'], getline(1, '$'))
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
389 " 3) forced linewise operation
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
390 %d_
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
391 call setline(1, ['aaa - bbb', 'x', 'ddd - eee'])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
392 call cursor(2, 1)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
393 norm dVi-
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
394 call assert_equal('noV', g:m)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
395 call assert_equal([''], getline(1, '$'))
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
396 " 4) forced blockwise operation
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
397 %d_
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
398 call setline(1, ['aaa - bbb', 'x', 'ddd - eee'])
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
399 call cursor(2, 1)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
400 exe "norm d\<C-V>i-"
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
401 call assert_equal("no\<C-V>", g:m)
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
402 call assert_equal(['aaabbb', 'x', 'dddeee'], getline(1, '$'))
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
403 bwipe!
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
404 delfunc Select
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
405 delfunc GetCommand
54457fc4af0b patch 8.1.0648: custom operators can't act upon a forced motion
Bram Moolenaar <Bram@vim.org>
parents: 13933
diff changeset
406 endfunc
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
407
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
408 func Test_error_in_map_expr()
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17249
diff changeset
409 " Unlike CheckRunVimInTerminal this does work in a win32 console
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17249
diff changeset
410 CheckFeature terminal
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17249
diff changeset
411 if has('win32') && has('gui_running')
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
412 throw 'Skipped: cannot run Vim in a terminal window'
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
413 endif
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
414
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
415 let lines =<< trim [CODE]
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
416 func Func()
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
417 " fail to create list
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
418 let x = [
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
419 endfunc
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
420 nmap <expr> ! Func()
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
421 set updatetime=50
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
422 [CODE]
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
423 call writefile(lines, 'Xtest.vim', 'D')
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
424
17249
3e2e998ce0db patch 8.1.1624: when testing in the GUI may try to run gvim in a terminal
Bram Moolenaar <Bram@vim.org>
parents: 17239
diff changeset
425 let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
426 let job = term_getjob(buf)
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
427 call WaitForAssert({-> assert_notequal('', term_getline(buf, 8))})
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
428
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
429 " GC must not run during map-expr processing, which can make Vim crash.
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
430 call term_sendkeys(buf, '!')
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
431 call TermWait(buf, 50)
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
432 call term_sendkeys(buf, "\<CR>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19407
diff changeset
433 call TermWait(buf, 50)
17184
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
434 call assert_equal('run', job_status(job))
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
435
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
436 call term_sendkeys(buf, ":qall!\<CR>")
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
437 call WaitFor({-> job_status(job) ==# 'dead'})
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
438 if has('unix')
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
439 call assert_equal('', job_info(job).termsig)
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
440 endif
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
441
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
442 exe buf .. 'bwipe!'
a5c3d374e1d3 patch 8.1.1591: on error garbage collection may free memory in use
Bram Moolenaar <Bram@vim.org>
parents: 16389
diff changeset
443 endfunc
18329
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
444
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
445 func Test_list_mappings()
18346
5b12fd0c39c3 patch 8.1.2167: mapping test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 18341
diff changeset
446 " Remove default mappings
5b12fd0c39c3 patch 8.1.2167: mapping test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 18341
diff changeset
447 imapclear
18341
a9d518b1271b patch 8.1.2165: mapping test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 18329
diff changeset
448
24375
fe4b6fc7149c patch 8.2.2728: special key names don't work if 'isident' is cleared
Bram Moolenaar <Bram@vim.org>
parents: 24204
diff changeset
449 " reset 'isident' to check it isn't used
fe4b6fc7149c patch 8.2.2728: special key names don't work if 'isident' is cleared
Bram Moolenaar <Bram@vim.org>
parents: 24204
diff changeset
450 set isident=
fe4b6fc7149c patch 8.2.2728: special key names don't work if 'isident' is cleared
Bram Moolenaar <Bram@vim.org>
parents: 24204
diff changeset
451 inoremap <C-m> CtrlM
18329
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
452 inoremap <A-S> AltS
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
453 inoremap <S-/> ShiftSlash
24375
fe4b6fc7149c patch 8.2.2728: special key names don't work if 'isident' is cleared
Bram Moolenaar <Bram@vim.org>
parents: 24204
diff changeset
454 set isident&
18329
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
455 call assert_equal([
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
456 \ 'i <S-/> * ShiftSlash',
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
457 \ 'i <M-S> * AltS',
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
458 \ 'i <C-M> * CtrlM',
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
459 \], execute('imap')->trim()->split("\n"))
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
460 iunmap <C-M>
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
461 iunmap <A-S>
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
462 call assert_equal(['i <S-/> * ShiftSlash'], execute('imap')->trim()->split("\n"))
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
463 iunmap <S-/>
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
464 call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n"))
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
465
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
466 " List global, buffer local and script local mappings
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
467 nmap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
468 nmap <buffer> ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
469 nmap <script> ,fs /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
470 call assert_equal(['n ,f @/^\k\+ (<CR>',
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
471 \ 'n ,fs & /^\k\+ (<CR>',
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
472 \ 'n ,f /^\k\+ (<CR>'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
473 \ execute('nmap ,f')->trim()->split("\n"))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
474
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
475 " List <Nop> mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
476 nmap ,n <Nop>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
477 call assert_equal(['n ,n <Nop>'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
478 \ execute('nmap ,n')->trim()->split("\n"))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
479
19178
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
480 " verbose map
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
481 call assert_match("\tLast set from .*/test_mapping.vim line \\d\\+$",
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
482 \ execute('verbose map ,n')->trim()->split("\n")[1])
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
483
28686
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
484 " character with K_SPECIAL byte in rhs
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
485 nmap foo …
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
486 call assert_equal(['n foo …'],
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
487 \ execute('nmap foo')->trim()->split("\n"))
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
488
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
489 " modified character with K_SPECIAL byte in rhs
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
490 nmap foo <M-…>
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
491 call assert_equal(['n foo <M-…>'],
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
492 \ execute('nmap foo')->trim()->split("\n"))
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
493
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
494 " character with K_SPECIAL byte in lhs
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
495 nmap … foo
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
496 call assert_equal(['n … foo'],
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
497 \ execute('nmap …')->trim()->split("\n"))
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
498
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
499 " modified character with K_SPECIAL byte in lhs
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
500 nmap <M-…> foo
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
501 call assert_equal(['n <M-…> foo'],
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
502 \ execute('nmap <M-…>')->trim()->split("\n"))
141fb1d233ba patch 8.2.4867: listing of mapping with K_SPECIAL is wrong
Bram Moolenaar <Bram@vim.org>
parents: 28668
diff changeset
503
28800
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
504 " illegal bytes
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
505 let str = ":\x7f:\x80:\x90:\xd0:"
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
506 exe 'nmap foo ' .. str
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
507 call assert_equal(['n foo ' .. strtrans(str)],
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
508 \ execute('nmap foo')->trim()->split("\n"))
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
509 unlet str
fea88e555652 patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents: 28686
diff changeset
510
19178
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
511 " map to CTRL-V
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
512 exe "nmap ,k \<C-V>"
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
513 call assert_equal(['n ,k <Nop>'],
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
514 \ execute('nmap ,k')->trim()->split("\n"))
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
515
24914
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
516 " map with space at the beginning
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
517 exe "nmap \<C-V> w <Nop>"
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
518 call assert_equal(['n <Space>w <Nop>'],
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
519 \ execute("nmap \<C-V> w")->trim()->split("\n"))
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
520
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
521 nmapclear
18329
1784afa654c8 patch 8.1.2159: some mappings are listed twice
Bram Moolenaar <Bram@vim.org>
parents: 17726
diff changeset
522 endfunc
18689
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
523
24142
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
524 func Test_expr_map_gets_cursor()
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
525 new
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
526 call setline(1, ['one', 'some w!rd'])
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
527 func StoreColumn()
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
528 let g:exprLine = line('.')
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
529 let g:exprCol = col('.')
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
530 return 'x'
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
531 endfunc
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
532 nnoremap <expr> x StoreColumn()
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
533 2
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
534 nmap ! f!<Ignore>x
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
535 call feedkeys("!", 'xt')
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
536 call assert_equal('some wrd', getline(2))
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
537 call assert_equal(2, g:exprLine)
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
538 call assert_equal(7, g:exprCol)
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
539
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
540 bwipe!
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
541 unlet g:exprLine
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
542 unlet g:exprCol
24144
dffac5e62db5 patch 8.2.2613: new test throws exception
Bram Moolenaar <Bram@vim.org>
parents: 24142
diff changeset
543 delfunc StoreColumn
24142
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
544 nunmap x
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
545 nunmap !
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
546 endfunc
34acfef7f60c patch 8.2.2612: col('.') may get outdated column value
Bram Moolenaar <Bram@vim.org>
parents: 23031
diff changeset
547
18689
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
548 func Test_expr_map_restore_cursor()
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
549 CheckScreendump
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
550
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
551 let lines =<< trim END
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
552 call setline(1, ['one', 'two', 'three'])
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
553 2
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
554 set ls=2
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
555 hi! link StatusLine ErrorMsg
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
556 noremap <expr> <C-B> Func()
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
557 func Func()
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
558 let g:on = !get(g:, 'on', 0)
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
559 redraws
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
560 return ''
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
561 endfunc
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
562 func Status()
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
563 return get(g:, 'on', 0) ? '[on]' : ''
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
564 endfunc
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
565 set stl=%{Status()}
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
566 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
567 call writefile(lines, 'XtestExprMap', 'D')
18689
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
568 let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
569 call term_sendkeys(buf, "\<C-B>")
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
570 call VerifyScreenDump(buf, 'Test_map_expr_1', {})
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
571
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
572 " clean up
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
573 call StopVimInTerminal(buf)
8cc12c8d7842 patch 8.1.2336: when an expr mapping moves the cursor it is not restored
Bram Moolenaar <Bram@vim.org>
parents: 18346
diff changeset
574 endfunc
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
575
27750
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
576 func Test_map_listing()
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
577 CheckScreendump
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
578
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
579 let lines =<< trim END
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
580 nmap a b
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
581 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
582 call writefile(lines, 'XtestMapList', 'D')
27750
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
583 let buf = RunVimInTerminal('-S XtestMapList', #{rows: 6})
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
584 call term_sendkeys(buf, ": nmap a\<CR>")
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
585 call VerifyScreenDump(buf, 'Test_map_list_1', {})
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
586
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
587 " clean up
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
588 call StopVimInTerminal(buf)
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
589 endfunc
fc0a37304590 patch 8.2.4401: map listing does not clear the rest of the command line
Bram Moolenaar <Bram@vim.org>
parents: 27624
diff changeset
590
27624
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
591 func Test_expr_map_error()
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
592 CheckScreendump
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
593
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
594 let lines =<< trim END
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
595 func Func()
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
596 throw 'test'
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
597 return ''
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
598 endfunc
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
599
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
600 nnoremap <expr> <F2> Func()
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
601 cnoremap <expr> <F2> Func()
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
602
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
603 call test_override('ui_delay', 10)
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
604 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
605 call writefile(lines, 'XtestExprMap', 'D')
27624
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
606 let buf = RunVimInTerminal('-S XtestExprMap', #{rows: 10})
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
607 call term_sendkeys(buf, "\<F2>")
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
608 call TermWait(buf)
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
609 call term_sendkeys(buf, "\<CR>")
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
610 call VerifyScreenDump(buf, 'Test_map_expr_2', {})
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
611
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
612 call term_sendkeys(buf, ":abc\<F2>")
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
613 call VerifyScreenDump(buf, 'Test_map_expr_3', {})
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
614 call term_sendkeys(buf, "\<Esc>0")
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
615 call VerifyScreenDump(buf, 'Test_map_expr_4', {})
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
616
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
617 " clean up
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
618 call StopVimInTerminal(buf)
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
619 endfunc
ec52847967d8 patch 8.2.4338: an error from an expression mapping messes up the display
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
620
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
621 " Test for mapping errors
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
622 func Test_map_error()
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
623 call assert_fails('unmap', 'E474:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
624 call assert_fails("exe 'map ' .. repeat('a', 51) .. ' :ls'", 'E474:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
625 call assert_fails('unmap abc', 'E31:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
626 call assert_fails('unabbr abc', 'E24:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
627 call assert_equal('', maparg(''))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
628 call assert_fails('echo maparg("abc", [])', 'E730:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
629
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
630 " unique map
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
631 map ,w /[#&!]<CR>
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
632 call assert_fails("map <unique> ,w /[#&!]<CR>", 'E227:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
633 " unique buffer-local map
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
634 call assert_fails("map <buffer> <unique> ,w /[.,;]<CR>", 'E225:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
635 unmap ,w
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
636
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
637 " unique abbreviation
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
638 abbr SP special
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
639 call assert_fails("abbr <unique> SP special", 'E226:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
640 " unique buffer-local map
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
641 call assert_fails("abbr <buffer> <unique> SP special", 'E224:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
642 unabbr SP
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
643
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
644 call assert_fails('mapclear abc', 'E474:')
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
645 call assert_fails('abclear abc', 'E474:')
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
646 call assert_fails('abbr $xyz abc', 'E474:')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
647
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
648 " space character in an abbreviation
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
649 call assert_fails('abbr ab<space> ABC', 'E474:')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
650
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
651 " invalid <expr> map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
652 map <expr> ,f abc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
653 call assert_fails('normal ,f', 'E121:')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
654 unmap <expr> ,f
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
655
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
656 " Recursive use of :normal in a map
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
657 set maxmapdepth=100
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
658 map gq :normal gq<CR>
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
659 call assert_fails('normal gq', 'E192:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
660 unmap gq
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19178
diff changeset
661 set maxmapdepth&
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
662 endfunc
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
663
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
664 " Test for <special> key mapping
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
665 func Test_map_special()
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
666 new
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
667 let old_cpo = &cpo
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
668 set cpo+=<
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
669 imap <F12> Blue
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
670 call feedkeys("i\<F12>", "x")
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
671 call assert_equal("<F12>", getline(1))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
672 call feedkeys("ddi<F12>", "x")
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
673 call assert_equal("Blue", getline(1))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
674 iunmap <F12>
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
675 imap <special> <F12> Green
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
676 call feedkeys("ddi\<F12>", "x")
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
677 call assert_equal("Green", getline(1))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
678 call feedkeys("ddi<F12>", "x")
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
679 call assert_equal("<F12>", getline(1))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
680 iunmap <special> <F12>
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
681 let &cpo = old_cpo
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
682 %bwipe!
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
683 endfunc
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
684
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
685 " Test for hasmapto()
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
686 func Test_hasmapto()
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
687 call assert_equal(0, hasmapto('/^\k\+ ('))
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
688 map ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
689 call assert_equal(1, hasmapto('/^\k\+ ('))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
690 unmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
691
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
692 " Insert mode mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
693 call assert_equal(0, hasmapto('/^\k\+ (', 'i'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
694 imap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
695 call assert_equal(1, hasmapto('/^\k\+ (', 'i'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
696 iunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
697
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
698 " Normal mode mapping
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
699 call assert_equal(0, hasmapto('/^\k\+ (', 'n'))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
700 nmap ,f /^\k\+ (<CR>
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
701 call assert_equal(1, hasmapto('/^\k\+ ('))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
702 call assert_equal(1, hasmapto('/^\k\+ (', 'n'))
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
703 nunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
704
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
705 " Visual and Select mode mapping
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
706 call assert_equal(0, hasmapto('/^\k\+ (', 'v'))
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
707 call assert_equal(0, hasmapto('/^\k\+ (', 'x'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
708 call assert_equal(0, hasmapto('/^\k\+ (', 's'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
709 vmap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
710 call assert_equal(1, hasmapto('/^\k\+ (', 'v'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
711 call assert_equal(1, hasmapto('/^\k\+ (', 'x'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
712 call assert_equal(1, hasmapto('/^\k\+ (', 's'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
713 vunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
714
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
715 " Visual mode mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
716 call assert_equal(0, hasmapto('/^\k\+ (', 'x'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
717 xmap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
718 call assert_equal(1, hasmapto('/^\k\+ (', 'v'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
719 call assert_equal(1, hasmapto('/^\k\+ (', 'x'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
720 call assert_equal(0, hasmapto('/^\k\+ (', 's'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
721 xunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
722
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
723 " Select mode mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
724 call assert_equal(0, hasmapto('/^\k\+ (', 's'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
725 smap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
726 call assert_equal(1, hasmapto('/^\k\+ (', 'v'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
727 call assert_equal(0, hasmapto('/^\k\+ (', 'x'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
728 call assert_equal(1, hasmapto('/^\k\+ (', 's'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
729 sunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
730
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
731 " Operator-pending mode mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
732 call assert_equal(0, hasmapto('/^\k\+ (', 'o'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
733 omap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
734 call assert_equal(1, hasmapto('/^\k\+ (', 'o'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
735 ounmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
736
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
737 " Language mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
738 call assert_equal(0, hasmapto('/^\k\+ (', 'l'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
739 lmap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
740 call assert_equal(1, hasmapto('/^\k\+ (', 'l'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
741 lunmap ,f
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
742
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
743 " Cmdline mode mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
744 call assert_equal(0, hasmapto('/^\k\+ (', 'c'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
745 cmap ,f /^\k\+ (<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
746 call assert_equal(1, hasmapto('/^\k\+ (', 'c'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
747 cunmap ,f
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
748
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
749 call assert_equal(0, hasmapto('/^\k\+ (', 'n', 1))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
750 endfunc
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
751
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
752 " Test for command-line completion of maps
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
753 func Test_mapcomplete()
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
754 call assert_equal(['<buffer>', '<expr>', '<nowait>', '<script>',
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
755 \ '<silent>', '<special>', '<unique>'],
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
756 \ getcompletion('', 'mapping'))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
757 call assert_equal([], getcompletion(',d', 'mapping'))
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
758
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
759 call feedkeys(":unmap <buf\<C-A>\<C-B>\"\<CR>", 'tx')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
760 call assert_equal('"unmap <buffer>', @:)
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
761
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
762 call feedkeys(":unabbr <buf\<C-A>\<C-B>\"\<CR>", 'tx')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
763 call assert_equal('"unabbr <buffer>', @:)
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
764
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
765 call feedkeys(":abbr! \<C-A>\<C-B>\"\<CR>", 'tx')
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
766 call assert_equal("\"abbr! \x01", @:)
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
767
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
768 " Multiple matches for a map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
769 nmap ,f /H<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
770 omap ,f /H<CR>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
771 call feedkeys(":map ,\<C-A>\<C-B>\"\<CR>", 'tx')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
772 call assert_equal('"map ,f', @:)
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
773 mapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
774 endfunc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
775
27221
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
776 func GetAbbrText()
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
777 unabbr hola
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
778 return 'hello'
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
779 endfunc
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
780
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
781 " Test for <expr> in abbreviation
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
782 func Test_expr_abbr()
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
783 new
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
784 iabbr <expr> teh "the"
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
785 call feedkeys("iteh ", "tx")
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
786 call assert_equal('the ', getline(1))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
787 iabclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
788 call setline(1, '')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
789
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
790 " invalid <expr> abbreviation
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
791 abbr <expr> hte GetAbbr()
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
792 call assert_fails('normal ihte ', 'E117:')
22742
f7f2d73ff85e patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
793 call assert_equal('', getline(1))
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
794 unabbr <expr> hte
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
795
27221
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
796 " evaluating the expression deletes the abbreviation
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
797 abbr <expr> hola GetAbbrText()
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
798 call assert_equal('GetAbbrText()', maparg('hola', 'i', '1'))
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
799 call feedkeys("ahola \<Esc>", 'xt')
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
800 call assert_equal('hello ', getline('.'))
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
801 call assert_equal('', maparg('hola', 'i', '1'))
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
802
165a799b4129 patch 8.2.4139: using freed memory in expression abbreviation
Bram Moolenaar <Bram@vim.org>
parents: 27169
diff changeset
803 bwipe!
19170
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
804 endfunc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
805
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
806 " Test for storing mappings in different modes in a vimrc file
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
807 func Test_mkvimrc_mapmodes()
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
808 map a1 /a1
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
809 nmap a2 /a2
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
810 vmap a3 /a3
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
811 smap a4 /a4
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
812 xmap a5 /a5
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
813 omap a6 /a6
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
814 map! a7 /a7
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
815 imap a8 /a8
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
816 lmap a9 /a9
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
817 cmap a10 /a10
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
818 tmap a11 /a11
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
819 " Normal + Visual map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
820 map a12 /a12
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
821 sunmap a12
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
822 ounmap a12
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
823 " Normal + Selectmode map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
824 map a13 /a13
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
825 xunmap a13
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
826 ounmap a13
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
827 " Normal + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
828 map a14 /a14
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
829 vunmap a14
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
830 " Visual + Selectmode map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
831 map a15 /a15
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
832 nunmap a15
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
833 ounmap a15
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
834 " Visual + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
835 map a16 /a16
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
836 nunmap a16
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
837 sunmap a16
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
838 " Selectmode + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
839 map a17 /a17
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
840 nunmap a17
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
841 xunmap a17
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
842 " Normal + Visual + Selectmode map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
843 map a18 /a18
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
844 ounmap a18
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
845 " Normal + Visual + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
846 map a19 /a19
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
847 sunmap a19
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
848 " Normal + Selectmode + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
849 map a20 /a20
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
850 xunmap a20
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
851 " Visual + Selectmode + OpPending map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
852 map a21 /a21
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
853 nunmap a21
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
854 " Mapping to Nop
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
855 map a22 <Nop>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
856 " Script local mapping
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
857 map <script> a23 /a23
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
858
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
859 " Newline in {lhs} and {rhs} of a map
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
860 exe "map a24\<C-V>\<C-J> ia24\<C-V>\<C-J><Esc>"
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
861
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
862 " Abbreviation
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
863 abbr a25 A25
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
864 cabbr a26 A26
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
865 iabbr a27 A27
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
866
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
867 mkvimrc! Xvimrc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
868 let l = readfile('Xvimrc')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
869 call assert_equal(['map a1 /a1'], filter(copy(l), 'v:val =~ " a1 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
870 call assert_equal(['nmap a2 /a2'], filter(copy(l), 'v:val =~ " a2 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
871 call assert_equal(['vmap a3 /a3'], filter(copy(l), 'v:val =~ " a3 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
872 call assert_equal(['smap a4 /a4'], filter(copy(l), 'v:val =~ " a4 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
873 call assert_equal(['xmap a5 /a5'], filter(copy(l), 'v:val =~ " a5 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
874 call assert_equal(['omap a6 /a6'], filter(copy(l), 'v:val =~ " a6 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
875 call assert_equal(['map! a7 /a7'], filter(copy(l), 'v:val =~ " a7 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
876 call assert_equal(['imap a8 /a8'], filter(copy(l), 'v:val =~ " a8 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
877 call assert_equal(['lmap a9 /a9'], filter(copy(l), 'v:val =~ " a9 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
878 call assert_equal(['cmap a10 /a10'], filter(copy(l), 'v:val =~ " a10 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
879 call assert_equal(['tmap a11 /a11'], filter(copy(l), 'v:val =~ " a11 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
880 call assert_equal(['nmap a12 /a12', 'xmap a12 /a12'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
881 \ filter(copy(l), 'v:val =~ " a12 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
882 call assert_equal(['nmap a13 /a13', 'smap a13 /a13'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
883 \ filter(copy(l), 'v:val =~ " a13 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
884 call assert_equal(['nmap a14 /a14', 'omap a14 /a14'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
885 \ filter(copy(l), 'v:val =~ " a14 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
886 call assert_equal(['vmap a15 /a15'], filter(copy(l), 'v:val =~ " a15 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
887 call assert_equal(['xmap a16 /a16', 'omap a16 /a16'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
888 \ filter(copy(l), 'v:val =~ " a16 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
889 call assert_equal(['smap a17 /a17', 'omap a17 /a17'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
890 \ filter(copy(l), 'v:val =~ " a17 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
891 call assert_equal(['nmap a18 /a18', 'vmap a18 /a18'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
892 \ filter(copy(l), 'v:val =~ " a18 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
893 call assert_equal(['nmap a19 /a19', 'xmap a19 /a19', 'omap a19 /a19'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
894 \ filter(copy(l), 'v:val =~ " a19 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
895 call assert_equal(['nmap a20 /a20', 'smap a20 /a20', 'omap a20 /a20'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
896 \ filter(copy(l), 'v:val =~ " a20 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
897 call assert_equal(['vmap a21 /a21', 'omap a21 /a21'],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
898 \ filter(copy(l), 'v:val =~ " a21 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
899 call assert_equal(['map a22 <Nop>'], filter(copy(l), 'v:val =~ " a22 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
900 call assert_equal([], filter(copy(l), 'v:val =~ " a23 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
901 call assert_equal(["map a24<NL> ia24<NL>\x16\e"],
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
902 \ filter(copy(l), 'v:val =~ " a24"'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
903
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
904 call assert_equal(['abbr a25 A25'], filter(copy(l), 'v:val =~ " a25 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
905 call assert_equal(['cabbr a26 A26'], filter(copy(l), 'v:val =~ " a26 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
906 call assert_equal(['iabbr a27 A27'], filter(copy(l), 'v:val =~ " a27 "'))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
907 call delete('Xvimrc')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
908
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
909 mapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
910 nmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
911 vmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
912 xmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
913 smapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
914 omapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
915 imapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
916 lmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
917 cmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
918 tmapclear
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
919 endfunc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
920
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
921 " Test for recursive mapping ('maxmapdepth')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
922 func Test_map_recursive()
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
923 map x y
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
924 map y x
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
925 call assert_fails('normal x', 'E223:')
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
926 unmap x
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
927 unmap y
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
928 endfunc
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
929
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
930 " Test for removing an abbreviation using {rhs} and with space after {lhs}
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
931 func Test_abbr_remove()
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
932 abbr foo bar
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
933 let d = maparg('foo', 'i', 1, 1)
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
934 call assert_equal(['foo', 'bar', '!'], [d.lhs, d.rhs, d.mode])
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
935 unabbr bar
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
936 call assert_equal({}, maparg('foo', 'i', 1, 1))
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
937
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
938 abbr foo bar
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
939 unabbr foo<space><tab>
ad40333f2ec0 patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 19149
diff changeset
940 call assert_equal({}, maparg('foo', 'i', 1, 1))
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
941 endfunc
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
942
19178
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
943 " Trigger an abbreviation using a special key
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
944 func Test_abbr_trigger_special()
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
945 new
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
946 iabbr teh the
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
947 call feedkeys("iteh\<F2>\<Esc>", 'xt')
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
948 call assert_equal('the<F2>', getline(1))
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
949 iunab teh
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
950 close!
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
951 endfunc
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
952
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
953 " Test for '<' in 'cpoptions'
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
954 func Test_map_cpo_special_keycode()
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
955 set cpo-=<
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
956 imap x<Bslash>k Test
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
957 let d = maparg('x<Bslash>k', 'i', 0, 1)
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
958 call assert_equal(['x\k', 'Test', 'i'], [d.lhs, d.rhs, d.mode])
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
959 call feedkeys(":imap x\<C-A>\<C-B>\"\<CR>", 'tx')
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
960 call assert_equal('"imap x\k', @:)
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
961 iunmap x<Bslash>k
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
962 set cpo+=<
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
963 imap x<Bslash>k Test
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
964 let d = maparg('x<Bslash>k', 'i', 0, 1)
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
965 call assert_equal(['x<Bslash>k', 'Test', 'i'], [d.lhs, d.rhs, d.mode])
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
966 call feedkeys(":imap x\<C-A>\<C-B>\"\<CR>", 'tx')
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
967 call assert_equal('"imap x<Bslash>k', @:)
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
968 iunmap x<Bslash>k
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
969 set cpo-=<
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
970 " Modifying 'cpo' above adds some default mappings, remove them
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
971 mapclear
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
972 mapclear!
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
973 endfunc
f7081bd2680e patch 8.2.0148: mapping related function in wrong source file
Bram Moolenaar <Bram@vim.org>
parents: 19170
diff changeset
974
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
975 " Test for <Cmd> key in maps to execute commands
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
976 func Test_map_cmdkey()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
977 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
978
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
979 " Error cases
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
980 let x = 0
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
981 noremap <F3> <Cmd><Cmd>let x = 1<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
982 call assert_fails('call feedkeys("\<F3>", "xt")', 'E1136:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
983 call assert_equal(0, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
984
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
985 noremap <F3> <Cmd><F3>let x = 2<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
986 call assert_fails('call feedkeys("\<F3>", "xt")', 'E1137:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
987 call assert_equal(0, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
988
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
989 noremap <F3> <Cmd>let x = 3
26717
3f209f13883d patch 8.2.3887: E1135 is used for two different errors
Bram Moolenaar <Bram@vim.org>
parents: 25969
diff changeset
990 call assert_fails('call feedkeys("\<F3>", "xt!")', 'E1255:')
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
991 call assert_equal(0, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
992
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
993 " works in various modes and sees the correct mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
994 noremap <F3> <Cmd>let m = mode(1)<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
995 noremap! <F3> <Cmd>let m = mode(1)<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
996
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
997 " normal mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
998 call feedkeys("\<F3>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
999 call assert_equal('n', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1000
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1001 " visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1002 call feedkeys("v\<F3>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1003 call assert_equal('v', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1004 " shouldn't leave the visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1005 call assert_equal('v', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1006 call feedkeys("\<Esc>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1007 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1008
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1009 " visual mapping in select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1010 call feedkeys("gh\<F3>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1011 call assert_equal('v', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1012 " shouldn't leave select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1013 call assert_equal('s', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1014 call feedkeys("\<Esc>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1015 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1016
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1017 " select mode mapping
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1018 snoremap <F3> <Cmd>let m = mode(1)<cr>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1019 call feedkeys("gh\<F3>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1020 call assert_equal('s', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1021 " shouldn't leave select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1022 call assert_equal('s', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1023 call feedkeys("\<Esc>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1024 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1025
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1026 " operator-pending mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1027 call feedkeys("d\<F3>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1028 call assert_equal('no', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1029 " leaves the operator-pending mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1030 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1031
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1032 " insert mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1033 call feedkeys("i\<F3>abc", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1034 call assert_equal('i', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1035 call assert_equal('abc', getline('.'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1036
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1037 " replace mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1038 call feedkeys("0R\<F3>two", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1039 call assert_equal('R', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1040 call assert_equal('two', getline('.'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1041
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1042 " virtual replace mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1043 call setline('.', "one\ttwo")
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1044 call feedkeys("4|gR\<F3>xxx", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1045 call assert_equal('Rv', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1046 call assert_equal("onexxx\ttwo", getline('.'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1047
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1048 " cmdline mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1049 call feedkeys(":\<F3>\"xxx\<CR>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1050 call assert_equal('c', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1051 call assert_equal('"xxx', @:)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1052
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1053 " terminal mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1054 if CanRunVimInTerminal()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1055 tnoremap <F3> <Cmd>let m = mode(1)<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1056 let buf = Run_shell_in_terminal({})
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1057 call feedkeys("\<F3>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1058 call assert_equal('t', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1059 call assert_equal('t', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1060 call StopShellInTerminal(buf)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1061 close!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1062 tunmap <F3>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1063 endif
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1064
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1065 " invoke cmdline mode recursively
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1066 noremap! <F2> <Cmd>norm! :foo<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1067 %d
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1068 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1069 call feedkeys(":bar\<F2>x\<C-B>\"\r", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1070 call assert_equal('"barx', @:)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1071 unmap! <F2>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1072
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1073 " test for calling a <SID> function
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1074 let lines =<< trim END
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1075 map <F2> <Cmd>call <SID>do_it()<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1076 func s:do_it()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1077 let g:x = 32
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1078 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1079 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
1080 call writefile(lines, 'Xscript', 'D')
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1081 source Xscript
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1082 call feedkeys("\<F2>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1083 call assert_equal(32, g:x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1084
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1085 unmap <F3>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1086 unmap! <F3>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1087 %bw!
23031
b68313ee7002 patch 8.2.2062: <Cmd> does not handle CTRL-V
Bram Moolenaar <Bram@vim.org>
parents: 22916
diff changeset
1088
b68313ee7002 patch 8.2.2062: <Cmd> does not handle CTRL-V
Bram Moolenaar <Bram@vim.org>
parents: 22916
diff changeset
1089 " command line ending in "0" is handled without errors
b68313ee7002 patch 8.2.2062: <Cmd> does not handle CTRL-V
Bram Moolenaar <Bram@vim.org>
parents: 22916
diff changeset
1090 onoremap ix <cmd>eval 0<cr>
b68313ee7002 patch 8.2.2062: <Cmd> does not handle CTRL-V
Bram Moolenaar <Bram@vim.org>
parents: 22916
diff changeset
1091 call feedkeys('dix.', 'xt')
b68313ee7002 patch 8.2.2062: <Cmd> does not handle CTRL-V
Bram Moolenaar <Bram@vim.org>
parents: 22916
diff changeset
1092 ounmap ix
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1093 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1094
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1095 " text object enters visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1096 func TextObj()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1097 if mode() !=# "v"
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1098 normal! v
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1099 end
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1100 call cursor(1, 3)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1101 normal! o
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1102 call cursor(2, 4)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1103 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1104
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1105 func s:cmdmap(lhs, rhs)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1106 exe 'noremap ' .. a:lhs .. ' <Cmd>' .. a:rhs .. '<CR>'
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1107 exe 'noremap! ' .. a:lhs .. ' <Cmd>' .. a:rhs .. '<CR>'
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1108 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1109
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1110 func s:cmdunmap(lhs)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1111 exe 'unmap ' .. a:lhs
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1112 exe 'unmap! ' .. a:lhs
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1113 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1114
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1115 " Map various <Fx> keys used by the <Cmd> key tests
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1116 func s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1117 call s:cmdmap('<F3>', 'let m = mode(1)')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1118 call s:cmdmap('<F4>', 'normal! ww')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1119 call s:cmdmap('<F5>', 'normal! "ay')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1120 call s:cmdmap('<F6>', 'throw "very error"')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1121 call s:cmdmap('<F7>', 'call TextObj()')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1122 call s:cmdmap('<F8>', 'startinsert')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1123 call s:cmdmap('<F9>', 'stopinsert')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1124 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1125
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1126 " Remove the mappings setup by setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1127 func s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1128 call s:cmdunmap('<F3>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1129 call s:cmdunmap('<F4>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1130 call s:cmdunmap('<F5>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1131 call s:cmdunmap('<F6>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1132 call s:cmdunmap('<F7>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1133 call s:cmdunmap('<F8>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1134 call s:cmdunmap('<F9>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1135 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1136
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1137 " Test for <Cmd> mapping in normal mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1138 func Test_map_cmdkey_normal_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1139 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1140 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1141
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1142 " check v:count and v:register works
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1143 call s:cmdmap('<F2>', 'let s = [mode(1), v:count, v:register]')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1144 call feedkeys("\<F2>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1145 call assert_equal(['n', 0, '"'], s)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1146 call feedkeys("7\<F2>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1147 call assert_equal(['n', 7, '"'], s)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1148 call feedkeys("\"e\<F2>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1149 call assert_equal(['n', 0, 'e'], s)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1150 call feedkeys("5\"k\<F2>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1151 call assert_equal(['n', 5, 'k'], s)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1152 call s:cmdunmap('<F2>')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1153
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1154 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1155 call feedkeys("\<F7>y", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1156 call assert_equal("me short lines\nof t", @")
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1157 call assert_equal('v', getregtype('"'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1158 call assert_equal([0, 1, 3, 0], getpos("'<"))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1159 call assert_equal([0, 2, 4, 0], getpos("'>"))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1160
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1161 " startinsert
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1162 %d
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1163 call feedkeys("\<F8>abc", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1164 call assert_equal('abc', getline(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1165
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1166 " feedkeys are not executed immediately
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1167 noremap ,a <Cmd>call feedkeys("aalpha") \| let g:a = getline(2)<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1168 %d
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1169 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1170 call cursor(2, 3)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1171 call feedkeys(",a\<F3>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1172 call assert_equal('of test text', g:a)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1173 call assert_equal('n', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1174 call assert_equal(['some short lines', 'of alphatest text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1175 nunmap ,a
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1176
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1177 " feedkeys(..., 'x') is executed immediately, but insert mode is aborted
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1178 noremap ,b <Cmd>call feedkeys("abeta", 'x') \| let g:b = getline(2)<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1179 call feedkeys(",b\<F3>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1180 call assert_equal('n', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1181 call assert_equal('of alphabetatest text', g:b)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1182 nunmap ,b
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1183
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1184 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1185 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1186 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1187
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1188 " Test for <Cmd> mapping with the :normal command
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1189 func Test_map_cmdkey_normal_cmd()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1190 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1191 noremap ,x <Cmd>call append(1, "xx") \| call append(1, "aa")<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1192 noremap ,f <Cmd>nosuchcommand<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1193 noremap ,e <Cmd>throw "very error" \| call append(1, "yy")<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1194 noremap ,m <Cmd>echoerr "The message." \| call append(1, "zz")<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1195 noremap ,w <Cmd>for i in range(5) \| if i==1 \| echoerr "Err" \| endif \| call append(1, i) \| endfor<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1196
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1197 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1198 exe "norm ,x\r"
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1199 call assert_equal(['some short lines', 'aa', 'xx', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1200
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1201 call assert_fails('norm ,f', 'E492:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1202 call assert_fails('norm ,e', 'very error')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1203 call assert_fails('norm ,m', 'The message.')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1204 call assert_equal(['some short lines', 'aa', 'xx', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1205
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1206 %d
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1207 let caught_err = 0
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1208 try
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1209 exe "normal ,w"
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1210 catch /Vim(echoerr):Err/
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1211 let caught_err = 1
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1212 endtry
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1213 call assert_equal(1, caught_err)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1214 call assert_equal(['', '0'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1215
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1216 %d
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1217 call assert_fails('normal ,w', 'Err')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1218 call assert_equal(['', '4', '3', '2' ,'1', '0'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1219 call assert_equal(1, line('.'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1220
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1221 nunmap ,x
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1222 nunmap ,f
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1223 nunmap ,e
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1224 nunmap ,m
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1225 nunmap ,w
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1226 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1227 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1228
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1229 " Test for <Cmd> mapping in visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1230 func Test_map_cmdkey_visual_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1231 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1232 set showmode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1233 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1234
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1235 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1236 call feedkeys("v\<F4>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1237 call assert_equal(['v', 1, 12], [mode(1), col('v'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1238
25969
a5a772dace5b patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 24914
diff changeset
1239 " can invoke an operator, ending the visual mode
22862
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1240 let @a = ''
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1241 call feedkeys("\<F5>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1242 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1243 call assert_equal('some short l', @a)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1244
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1245 " error doesn't interrupt visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1246 call assert_fails('call feedkeys("ggvw\<F6>", "xt!")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1247 call assert_equal(['v', 1, 6], [mode(1), col('v'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1248 call feedkeys("\<F7>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1249 call assert_equal(['v', 1, 3, 2, 4], [mode(1), line('v'), col('v'), line('.'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1250
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1251 " startinsert gives "-- (insert) VISUAL --" mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1252 call feedkeys("\<F8>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1253 call assert_equal(['v', 1, 3, 2, 4], [mode(1), line('v'), col('v'), line('.'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1254 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1255 call assert_match('^-- (insert) VISUAL --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1256 call feedkeys("\<Esc>new ", 'x')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1257 call assert_equal(['some short lines', 'of new test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1258
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1259 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1260 set showmode&
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1261 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1262 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1263
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1264 " Test for <Cmd> mapping in select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1265 func Test_map_cmdkey_select_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1266 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1267 set showmode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1268 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1269
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1270 snoremap <F1> <cmd>throw "very error"<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1271 snoremap <F2> <cmd>normal! <c-g>"by<CR>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1272 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1273
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1274 call feedkeys("gh\<F4>", "xt!")
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1275 call assert_equal(['s', 1, 12], [mode(1), col('v'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1276 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1277 call assert_match('^-- SELECT --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1278
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1279 " visual mapping in select mode restarts select mode after operator
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1280 let @a = ''
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1281 call feedkeys("\<F5>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1282 call assert_equal('s', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1283 call assert_equal('some short l', @a)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1284
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1285 " select mode mapping works, and does not restart select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1286 let @b = ''
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1287 call feedkeys("\<F2>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1288 call assert_equal('n', mode(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1289 call assert_equal('some short l', @b)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1290
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1291 " error doesn't interrupt temporary visual mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1292 call assert_fails('call feedkeys("\<Esc>ggvw\<C-G>\<F6>", "xt!")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1293 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1294 call assert_match('^-- VISUAL --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1295 " quirk: restoration of select mode is not performed
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1296 call assert_equal(['v', 1, 6], [mode(1), col('v'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1297
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1298 " error doesn't interrupt select mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1299 call assert_fails('call feedkeys("\<Esc>ggvw\<C-G>\<F1>", "xt!")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1300 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1301 call assert_match('^-- SELECT --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1302 call assert_equal(['s', 1, 6], [mode(1), col('v'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1303
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1304 call feedkeys("\<F7>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1305 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1306 call assert_match('^-- SELECT --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1307 call assert_equal(['s', 1, 3, 2, 4], [mode(1), line('v'), col('v'), line('.'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1308
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1309 " startinsert gives "-- SELECT (insert) --" mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1310 call feedkeys("\<F8>", 'xt!')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1311 redraw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1312 call assert_match('^-- (insert) SELECT --', Screenline(&lines))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1313 call assert_equal(['s', 1, 3, 2, 4], [mode(1), line('v'), col('v'), line('.'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1314 call feedkeys("\<Esc>new ", 'x')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1315 call assert_equal(['some short lines', 'of new test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1316
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1317 sunmap <F1>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1318 sunmap <F2>
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1319 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1320 set showmode&
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1321 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1322 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1323
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1324 " Test for <Cmd> mapping in operator-pending mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1325 func Test_map_cmdkey_op_pending_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1326 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1327 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1328
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1329 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1330 call feedkeys("d\<F4>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1331 call assert_equal(['lines', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1332 call assert_equal(['some short '], getreg('"', 1, 1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1333 " create a new undo point
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1334 let &undolevels = &undolevels
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1335
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1336 call feedkeys(".", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1337 call assert_equal(['test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1338 call assert_equal(['lines', 'of '], getreg('"', 1, 1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1339 " create a new undo point
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1340 let &undolevels = &undolevels
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1341
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1342 call feedkeys("uu", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1343 call assert_equal(['some short lines', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1344
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1345 " error aborts operator-pending, operator not performed
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1346 call assert_fails('call feedkeys("d\<F6>", "xt")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1347 call assert_equal(['some short lines', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1348
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1349 call feedkeys("\"bd\<F7>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1350 call assert_equal(['soest text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1351 call assert_equal(['me short lines', 'of t'], getreg('b', 1, 1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1352
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1353 " startinsert aborts operator
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1354 call feedkeys("d\<F8>cc", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1355 call assert_equal(['soccest text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1356
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1357 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1358 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1359 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1360
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1361 " Test for <Cmd> mapping in insert mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1362 func Test_map_cmdkey_insert_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1363 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1364 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1365
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1366 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1367 " works the same as <C-O>w<C-O>w
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1368 call feedkeys("iindeed \<F4>little ", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1369 call assert_equal(['indeed some short little lines', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1370 call assert_fails('call feedkeys("i\<F6> 2", "xt")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1371 call assert_equal(['indeed some short little 2 lines', 'of test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1372
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1373 " Note when entering visual mode from InsertEnter autocmd, an async event,
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1374 " or a <Cmd> mapping, vim ends up in undocumented "INSERT VISUAL" mode.
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1375 call feedkeys("i\<F7>stuff ", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1376 call assert_equal(['indeed some short little 2 lines', 'of stuff test text'], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1377 call assert_equal(['v', 1, 3, 2, 9], [mode(1), line('v'), col('v'), line('.'), col('.')])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1378
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1379 call feedkeys("\<F5>", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1380 call assert_equal(['deed some short little 2 lines', 'of stuff '], getreg('a', 1, 1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1381
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1382 " also works as part of abbreviation
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1383 abbr foo <Cmd>let g:y = 17<CR>bar
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1384 exe "normal i\<space>foo "
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1385 call assert_equal(17, g:y)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1386 call assert_equal('in bar deed some short little 2 lines', getline(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1387 unabbr foo
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1388
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1389 " :startinsert does nothing
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1390 call setline(1, 'foo bar')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1391 call feedkeys("ggi\<F8>vim", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1392 call assert_equal('vimfoo bar', getline(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1393
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1394 " :stopinsert works
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1395 call feedkeys("ggi\<F9>Abc", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1396 call assert_equal('vimfoo barbc', getline(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1397
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1398 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1399 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1400 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1401
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1402 " Test for <Cmd> mapping in insert-completion mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1403 func Test_map_cmdkey_insert_complete_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1404 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1405 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1406
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1407 call setline(1, 'some short lines')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1408 call feedkeys("os\<C-X>\<C-N>\<F3>\<C-N> ", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1409 call assert_equal('ic', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1410 call assert_equal(['some short lines', 'short '], getline(1, '$'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1411
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1412 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1413 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1414 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1415
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1416 " Test for <Cmd> mapping in cmdline mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1417 func Test_map_cmdkey_cmdline_mode()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1418 new
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1419 call s:setupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1420
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1421 call setline(1, ['some short lines', 'of test text'])
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1422 let x = 0
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1423 call feedkeys(":let x\<F3>= 10\r", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1424 call assert_equal('c', m)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1425 call assert_equal(10, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1426
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1427 " exception doesn't leave cmdline mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1428 call assert_fails('call feedkeys(":let x\<F6>= 20\r", "xt")', 'E605:')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1429 call assert_equal(20, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1430
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1431 " move cursor in the buffer from cmdline mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1432 call feedkeys(":let x\<F4>= 30\r", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1433 call assert_equal(30, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1434 call assert_equal(12, col('.'))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1435
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1436 " :startinsert takes effect after leaving cmdline mode
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1437 call feedkeys(":let x\<F8>= 40\rnew ", 'xt')
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1438 call assert_equal(40, x)
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1439 call assert_equal('some short new lines', getline(1))
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1440
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1441 call s:cleanupMaps()
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1442 %bw!
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1443 endfunc
6d50182e7e24 patch 8.2.1978: making a mapping work in all modes is complicated
Bram Moolenaar <Bram@vim.org>
parents: 22742
diff changeset
1444
22916
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1445 func Test_map_cmdkey_redo()
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1446 func SelectDash()
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1447 call search('^---\n\zs', 'bcW')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1448 norm! V
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1449 call search('\n\ze---$', 'W')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1450 endfunc
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1451
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1452 let text =<< trim END
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1453 ---
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1454 aaa
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1455 ---
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1456 bbb
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1457 bbb
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1458 ---
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1459 ccc
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1460 ccc
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1461 ccc
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1462 ---
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1463 END
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1464 new Xcmdtext
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1465 call setline(1, text)
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1466
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1467 onoremap <silent> i- <Cmd>call SelectDash()<CR>
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1468 call feedkeys('2Gdi-', 'xt')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1469 call assert_equal(['---', '---'], getline(1, 2))
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1470 call feedkeys('j.', 'xt')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1471 call assert_equal(['---', '---', '---'], getline(1, 3))
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1472 call feedkeys('j.', 'xt')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1473 call assert_equal(['---', '---', '---', '---'], getline(1, 4))
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1474
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1475 bwipe!
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1476 call delete('Xcmdtext')
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1477 delfunc SelectDash
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1478 ounmap i-
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1479 endfunc
1fe53aae3ba0 patch 8.2.2005: redoing a mapping with <Cmd> doesn't work properly
Bram Moolenaar <Bram@vim.org>
parents: 22862
diff changeset
1480
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1481 func Test_map_script_cmd_restore()
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1482 let lines =<< trim END
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1483 vim9script
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1484 nnoremap <F3> <ScriptCmd>eval 1 + 2<CR>
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1485 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27241
diff changeset
1486 call v9.CheckScriptSuccess(lines)
27156
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1487 call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc')
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1488 call assert_equal(7, g:result)
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1489
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1490 nunmap <F3>
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1491 unlet g:result
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1492 endfunc
67194006cad8 patch 8.2.4107: script context not restored after using <ScriptCmd>
Bram Moolenaar <Bram@vim.org>
parents: 27098
diff changeset
1493
27169
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1494 func Test_map_script_cmd_finds_func()
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1495 let lines =<< trim END
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1496 vim9script
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1497 onoremap <F3> <ScriptCmd>Func()<CR>
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1498 def Func()
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1499 g:func_called = 'yes'
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1500 enddef
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1501 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27241
diff changeset
1502 call v9.CheckScriptSuccess(lines)
27169
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1503 call feedkeys("y\<F3>\<Esc>", 'xtc')
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1504 call assert_equal('yes', g:func_called)
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1505
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1506 ounmap <F3>
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1507 unlet g:func_called
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1508 endfunc
1af5263a4509 patch 8.2.4113: typo on DOCMD_RANGEOK results in not recognizing command
Bram Moolenaar <Bram@vim.org>
parents: 27156
diff changeset
1509
27239
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1510 func Test_map_script_cmd_survives_unmap()
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1511 let lines =<< trim END
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1512 vim9script
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1513 var n = 123
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1514 nnoremap <F4> <ScriptCmd><CR>
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1515 autocmd CmdlineEnter * silent! nunmap <F4>
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1516 nnoremap <F3> :<ScriptCmd>eval setbufvar(bufnr(), "result", n)<CR>
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1517 feedkeys("\<F3>\<CR>", 'xct')
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1518 assert_equal(123, b:result)
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1519 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27241
diff changeset
1520 call v9.CheckScriptSuccess(lines)
27239
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1521
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1522 nunmap <F3>
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1523 unlet b:result
27241
959d6a664cfd patch 8.2.4149: test override not restored, autocommand left behind
Bram Moolenaar <Bram@vim.org>
parents: 27239
diff changeset
1524 autocmd! CmdlineEnter
27239
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1525 endfunc
bd072d44eb2c patch 8.2.4148: deleting any mapping may cause <ScritpCmd> to fail
Bram Moolenaar <Bram@vim.org>
parents: 27221
diff changeset
1526
30102
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1527 func Test_map_script_cmd_redo()
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
1528 call mkdir('Xmapcmd', 'R')
30102
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1529 let lines =<< trim END
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1530 vim9script
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1531 import autoload './script.vim'
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1532 onoremap <F3> <ScriptCmd>script.Func()<CR>
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1533 END
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1534 call writefile(lines, 'Xmapcmd/plugin.vim')
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1535
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1536 let lines =<< trim END
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1537 vim9script
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1538 export def Func()
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1539 normal! dd
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1540 enddef
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1541 END
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1542 call writefile(lines, 'Xmapcmd/script.vim')
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1543 new
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1544 call setline(1, ['one', 'two', 'three', 'four'])
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1545 nnoremap j j
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1546 source Xmapcmd/plugin.vim
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1547 call feedkeys("d\<F3>j.", 'xt')
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1548 call assert_equal(['two', 'four'], getline(1, '$'))
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1549
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1550 ounmap <F3>
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1551 nunmap j
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1552 bwipe!
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1553 endfunc
539fb427124d patch 9.0.0387: repeat <ScriptCmd> mapping doesn't use right script context
Bram Moolenaar <Bram@vim.org>
parents: 29350
diff changeset
1554
24204
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1555 " Test for using <script> with a map to remap characters in rhs
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1556 func Test_script_local_remap()
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1557 new
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1558 inoremap <buffer> <SID>xyz mno
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1559 inoremap <buffer> <script> abc st<SID>xyzre
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1560 normal iabc
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1561 call assert_equal('stmnore', getline(1))
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1562 bwipe!
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1563 endfunc
ec71c859e94c patch 8.2.2643: various code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 24144
diff changeset
1564
24559
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1565 func Test_abbreviate_multi_byte()
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1566 new
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1567 iabbrev foo bar
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1568 call feedkeys("ifoo…\<Esc>", 'xt')
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1569 call assert_equal("bar…", getline(1))
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1570 iunabbrev foo
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1571 bwipe!
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1572 endfunc
839145e0fdaa patch 8.2.2819: finishing an abbreviation with multi-byte char may not work
Bram Moolenaar <Bram@vim.org>
parents: 24375
diff changeset
1573
24914
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1574 " Test for abbreviations with 'latin1' encoding
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1575 func Test_abbreviate_latin1_encoding()
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1576 set encoding=latin1
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1577 call assert_fails('abbr ab#$c ABC', 'E474:')
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1578 new
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1579 iabbr <buffer> #i #include
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1580 iabbr <buffer> ## #enddef
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1581 exe "normal i#i\<C-]>"
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1582 call assert_equal('#include', getline(1))
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1583 exe "normal 0Di##\<C-]>"
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1584 call assert_equal('#enddef', getline(1))
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1585 %bw!
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1586 set encoding=utf-8
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1587 endfunc
1186160ecf57 patch 8.2.2994: various code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24559
diff changeset
1588
27946
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1589 " Test for <Plug> always being mapped, even when used with "noremap".
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1590 func Test_plug_remap()
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1591 let g:foo = 0
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1592 nnoremap <Plug>(Increase_x) <Cmd>let g:foo += 1<CR>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1593 nmap <F2> <Plug>(Increase_x)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1594 nnoremap <F3> <Plug>(Increase_x)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1595 call feedkeys("\<F2>", 'xt')
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1596 call assert_equal(1, g:foo)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1597 call feedkeys("\<F3>", 'xt')
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1598 call assert_equal(2, g:foo)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1599 nnoremap x <Nop>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1600 nmap <F4> x<Plug>(Increase_x)x
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1601 nnoremap <F5> x<Plug>(Increase_x)x
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1602 call setline(1, 'Some text')
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1603 normal! gg$
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1604 call feedkeys("\<F4>", 'xt')
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1605 call assert_equal(3, g:foo)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1606 call assert_equal('Some text', getline(1))
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1607 call feedkeys("\<F5>", 'xt')
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1608 call assert_equal(4, g:foo)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1609 call assert_equal('Some te', getline(1))
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1610 nunmap <Plug>(Increase_x)
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1611 nunmap <F2>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1612 nunmap <F3>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1613 nunmap <F4>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1614 nunmap <F5>
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1615 unlet g:foo
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1616 %bw!
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1617 endfunc
5147f3d3ed30 patch 8.2.4498: using <Plug> with "noremap" does not work
Bram Moolenaar <Bram@vim.org>
parents: 27750
diff changeset
1618
28588
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1619 func Test_mouse_drag_mapped_start_select()
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1620 set mouse=a
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1621 set selectmode=key,mouse
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1622 func ClickExpr()
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1623 call test_setmouse(1, 1)
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1624 return "\<LeftMouse>"
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1625 endfunc
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1626 func DragExpr()
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1627 call test_setmouse(1, 2)
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1628 return "\<LeftDrag>"
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1629 endfunc
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1630 nnoremap <expr> <F2> ClickExpr()
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1631 nmap <expr> <F3> DragExpr()
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1632
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1633 nnoremap <LeftDrag> <LeftDrag><Cmd><CR>
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1634 exe "normal \<F2>\<F3>"
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1635 call assert_equal('s', mode())
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1636 exe "normal! \<C-\>\<C-N>"
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1637
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1638 nunmap <LeftDrag>
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1639 nunmap <F2>
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1640 nunmap <F3>
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1641 delfunc ClickExpr
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1642 delfunc DragExpr
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1643 set selectmode&
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1644 set mouse&
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1645 endfunc
a1de4ee8c40d patch 8.2.4818: no test for what 8.2.4806 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28333
diff changeset
1646
28333
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1647 " Test for mapping <LeftDrag> in Insert mode
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1648 func Test_mouse_drag_insert_map()
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1649 set mouse=a
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1650 func ClickExpr()
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1651 call test_setmouse(1, 1)
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1652 return "\<LeftMouse>"
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1653 endfunc
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1654 func DragExpr()
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1655 call test_setmouse(1, 2)
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1656 return "\<LeftDrag>"
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1657 endfunc
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1658 inoremap <expr> <F2> ClickExpr()
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1659 imap <expr> <F3> DragExpr()
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1660
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1661 inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1662 exe "normal i\<F2>\<F3>"
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1663 call assert_equal(1, g:dragged)
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1664 call assert_equal('v', mode())
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1665 exe "normal! \<C-\>\<C-N>"
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1666 unlet g:dragged
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1667
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1668 inoremap <LeftDrag> <LeftDrag><C-\><C-N>
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1669 exe "normal i\<F2>\<F3>"
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1670 call assert_equal('n', mode())
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1671
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1672 iunmap <LeftDrag>
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1673 iunmap <F2>
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1674 iunmap <F3>
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1675 delfunc ClickExpr
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1676 delfunc DragExpr
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1677 set mouse&
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1678 endfunc
04310f81143d patch 8.2.4692: no test for what 8.2.4691 fixes
Bram Moolenaar <Bram@vim.org>
parents: 27946
diff changeset
1679
28608
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1680 func Test_unmap_simplifiable()
28590
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1681 map <C-I> foo
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1682 map <Tab> bar
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1683 call assert_equal('foo', maparg('<C-I>'))
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1684 call assert_equal('bar', maparg('<Tab>'))
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1685 unmap <C-I>
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1686 call assert_equal('', maparg('<C-I>'))
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1687 call assert_equal('bar', maparg('<Tab>'))
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1688 unmap <Tab>
28608
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1689
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1690 map <C-I> foo
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1691 unmap <Tab>
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1692 " This should not error
9ae7ccd90041 patch 8.2.4828: fix for unmapping simplified key not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 28590
diff changeset
1693 unmap <C-I>
28590
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1694 endfunc
86bf2dabc93a patch 8.2.4819: unmapping simplified keys also deletes other mapping
Bram Moolenaar <Bram@vim.org>
parents: 28588
diff changeset
1695
28668
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1696 func Test_expr_map_escape_special()
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1697 nnoremap … <Cmd>let g:got_ellipsis += 1<CR>
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1698 func Func()
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1699 return '…'
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1700 endfunc
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1701 nmap <expr> <F2> Func()
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1702 let g:got_ellipsis = 0
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1703 call feedkeys("\<F2>", 'xt')
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1704 call assert_equal(1, g:got_ellipsis)
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1705 delfunc Func
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1706 nunmap <F2>
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1707 unlet g:got_ellipsis
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1708 nunmap …
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1709 endfunc
53c608c7ea9e patch 8.2.4858: K_SPECIAL may be escaped twice
Bram Moolenaar <Bram@vim.org>
parents: 28608
diff changeset
1710
29085
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1711 " Testing for mapping after an <Nop> mapping is triggered on timeout.
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1712 " Test for what patch 8.1.0052 fixes.
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1713 func Test_map_after_timed_out_nop()
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1714 CheckRunVimInTerminal
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1715
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1716 let lines =<< trim END
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1717 set timeout timeoutlen=400
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1718 inoremap ab TEST
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1719 inoremap a <Nop>
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1720 END
30582
72245f9c9405 patch 9.0.0626: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30102
diff changeset
1721 call writefile(lines, 'Xtest_map_after_timed_out_nop', 'D')
29085
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1722 let buf = RunVimInTerminal('-S Xtest_map_after_timed_out_nop', #{rows: 6})
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1723
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1724 " Enter Insert mode
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1725 call term_sendkeys(buf, 'i')
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1726 " Wait for the "a" mapping to timeout
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1727 call term_sendkeys(buf, 'a')
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1728 call term_wait(buf, 500)
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1729 " Send "a" and wait for a period shorter than 'timeoutlen'
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1730 call term_sendkeys(buf, 'a')
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1731 call term_wait(buf, 100)
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1732 " Send "b", should trigger the "ab" mapping
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1733 call term_sendkeys(buf, 'b')
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1734 call WaitForAssert({-> assert_equal("TEST", term_getline(buf, 1))})
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1735
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1736 " clean up
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1737 call StopVimInTerminal(buf)
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1738 endfunc
ae39554ad2ee patch 8.2.5064: no test for what 8.1.0052 fixes
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
1739
29350
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1740 func Test_using_past_typeahead()
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1741 nnoremap :00 0
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1742 exe "norm :set \x80\xfb0=0\<CR>"
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1743 exe "sil norm :0\x0f\<C-U>\<CR>"
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1744
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1745 exe "norm :set \x80\xfb0=\<CR>"
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1746 nunmap :00
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1747 endfunc
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1748
8a822186f1ab patch 9.0.0018: going over the end of the typahead
Bram Moolenaar <Bram@vim.org>
parents: 29085
diff changeset
1749
19149
643c6c3c0da4 patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents: 18689
diff changeset
1750 " vim: shiftwidth=2 sts=2 expandtab