Mercurial > vim
annotate src/testdir/test_map_functions.vim @ 32764:d35204b890af v9.0.1701
patch 9.0.1701: vim9 crash when class member overridden
Commit: https://github.com/vim/vim/commit/57a02ccf4c75a6abb270194c90be926d5221b3ce
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Aug 13 10:19:38 2023 +0200
patch 9.0.1701: vim9 crash when class member overridden
Problem: vim9 crash when class member overridden
Solution: Use method_count field instead
closes: #12676
closes: #12677
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 13 Aug 2023 10:30:07 +0200 |
parents | 39b1788b1765 |
children | 5c3d243ae124 |
rev | line source |
---|---|
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
1 " Tests for maparg(), mapcheck(), mapset(), maplist() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Also test utf8 map with a 0x80 byte. |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 |
32222
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
4 source shared.vim |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
5 |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
6 func s:SID() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')) |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
8 endfunc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
10 func Test_maparg() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 set cpo-=< |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 set encoding=utf8 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " Test maparg() with a string result |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
15 let sid = s:SID() |
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
16 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 map foo<C-V> is<F4>foo |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 vnoremap <script> <buffer> <expr> <silent> bar isbar |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call assert_equal("is<F4>foo", maparg('foo<C-V>')) |
19870
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19170
diff
changeset
|
20 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>', |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
21 \ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16", |
27223
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
22 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1, |
31849
dbec60b8c253
patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents:
30986
diff
changeset
|
23 \ 'lnum': lnum + 1, |
28817
1ad71fcbf546
patch 8.2.4932: not easy to filter the output of maplist()
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
24 \ 'rhs': 'is<F4>foo', 'buffer': 0, 'abbr': 0, 'mode_bits': 0x47}, |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
25 \ maparg('foo<C-V>', '', 0, 1)) |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
26 call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
27 \ 'lhsraw': 'bar', 'mode': 'v', |
27223
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
28 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'scriptversion': 1, |
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
29 \ 'lnum': lnum + 2, |
28817
1ad71fcbf546
patch 8.2.4932: not easy to filter the output of maplist()
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
30 \ 'rhs': 'isbar', 'buffer': 1, 'abbr': 0, 'mode_bits': 0x42}, |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
31 \ 'bar'->maparg('', 0, 1)) |
14700
0a3b9ecf7cb8
patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents:
13986
diff
changeset
|
32 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 map <buffer> <nowait> foo bar |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
34 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
35 \ 'lhsraw': 'foo', 'mode': ' ', |
27223
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
36 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'scriptversion': 1, |
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
37 \ 'lnum': lnum + 1, 'rhs': 'bar', |
28817
1ad71fcbf546
patch 8.2.4932: not easy to filter the output of maplist()
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
38 \ 'buffer': 1, 'abbr': 0, 'mode_bits': 0x47}, |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 \ maparg('foo', '', 0, 1)) |
17522
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
40 let lnum = expand('<sflnum>') |
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
41 tmap baz foo |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
42 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
43 \ 'lhsraw': 'baz', 'mode': 't', |
27223
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
44 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1, |
ea2b4cb4515b
patch 8.2.4140: maparg() does not indicate the type of script
Bram Moolenaar <Bram@vim.org>
parents:
24529
diff
changeset
|
45 \ 'lnum': lnum + 1, 'rhs': 'foo', |
28817
1ad71fcbf546
patch 8.2.4932: not easy to filter the output of maplist()
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
46 \ 'buffer': 0, 'abbr': 0, 'mode_bits': 0x80}, |
17522
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
47 \ maparg('baz', 't', 0, 1)) |
28674
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
48 let lnum = expand('<sflnum>') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
49 iab A B |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
50 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'A', |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
51 \ 'lhsraw': 'A', 'mode': 'i', |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
52 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'scriptversion': 1, |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
53 \ 'lnum': lnum + 1, 'rhs': 'B', |
28817
1ad71fcbf546
patch 8.2.4932: not easy to filter the output of maplist()
Bram Moolenaar <Bram@vim.org>
parents:
28800
diff
changeset
|
54 \ 'buffer': 0, 'abbr': 1, 'mode_bits': 0x0010}, |
28674
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
55 \ maparg('A', 'i', 1, 1)) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
56 iuna A |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 map abc x<char-114>x |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
59 call assert_equal("xrx", maparg('abc')) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 map abc y<S-char-114>y |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
61 call assert_equal("yRy", maparg('abc')) |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
62 |
28800
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
63 " character with K_SPECIAL byte |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
64 nmap abc … |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
65 call assert_equal('…', maparg('abc')) |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
66 |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
67 " modified character with K_SPECIAL byte |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
68 nmap abc <M-…> |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
69 call assert_equal('<M-…>', maparg('abc')) |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
70 |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
71 " illegal bytes |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
72 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:
28674
diff
changeset
|
73 exe 'nmap abc ' .. str |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
74 call assert_equal(str, maparg('abc')) |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
75 unlet str |
fea88e555652
patch 8.2.4924: maparg() may return a string that cannot be reused
Bram Moolenaar <Bram@vim.org>
parents:
28674
diff
changeset
|
76 |
19149
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
77 omap { w |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
78 let d = maparg('{', 'o', 0, 1) |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
79 call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode]) |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
80 ounmap { |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
81 |
19170
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
82 lmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
83 let d = maparg('{', 'l', 0, 1) |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
84 call assert_equal(['{', 'w', 'l'], [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
|
85 lunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
86 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
87 nmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
88 let d = maparg('{', 'n', 0, 1) |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
89 call assert_equal(['{', 'w', 'n'], [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
|
90 nunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
91 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
92 xmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
93 let d = maparg('{', 'x', 0, 1) |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
94 call assert_equal(['{', 'w', 'x'], [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
|
95 xunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
96 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
97 smap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
98 let d = maparg('{', 's', 0, 1) |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
99 call assert_equal(['{', 'w', 's'], [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
|
100 sunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
101 |
28614
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
102 map <C-I> foo |
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
103 unmap <Tab> |
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
104 " This used to cause a segfault |
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
105 call maparg('<C-I>', '', 0, 1) |
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
106 unmap <C-I> |
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
107 |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
108 map abc <Nop> |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
109 call assert_equal("<Nop>", maparg('abc')) |
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
110 unmap abc |
19170
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
111 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
112 call feedkeys(":abbr esc \<C-V>\<C-V>\<C-V>\<C-V>\<C-V>\<Esc>\<CR>", "xt") |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
113 let d = maparg('esc', 'i', 1, 1) |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
114 call assert_equal(['esc', "\<C-V>\<C-V>\<Esc>", '!'], [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
|
115 abclear |
28614
9ae2c32841fb
patch 8.2.4831: crash when using maparg() and unmapping simplified keys
Bram Moolenaar <Bram@vim.org>
parents:
28602
diff
changeset
|
116 unlet d |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
117 endfunc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 |
21695
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
119 def Test_vim9_maparg() |
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
120 nmap { w |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
121 var one: string = maparg('{') |
21695
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
122 assert_equal('w', one) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
123 var two: string = maparg('{', 'n') |
21695
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
124 assert_equal('w', two) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
125 var three: string = maparg('{', 'n', 0) |
21695
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
126 assert_equal('w', three) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22147
diff
changeset
|
127 var four: dict<any> = maparg('{', 'n', 0, 1) |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
21695
diff
changeset
|
128 assert_equal(['{', 'w', 'n'], [four.lhs, four.rhs, four.mode]) |
21695
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
129 nunmap { |
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
130 enddef |
f27187782dc6
patch 8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg
Bram Moolenaar <Bram@vim.org>
parents:
20522
diff
changeset
|
131 |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
132 func Test_mapcheck() |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
133 call assert_equal('', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
134 call assert_equal('', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
135 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
136 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
137 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
138 map a something |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
139 call assert_equal('something', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
140 call assert_equal('something', mapcheck('a', 'n')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
141 call assert_equal('', mapcheck('a', 'c')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
142 call assert_equal('', mapcheck('a', 'i')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
143 call assert_equal('something', 'abc'->mapcheck()) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
144 call assert_equal('something', 'ax'->mapcheck()) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
145 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
146 unmap a |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
147 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
148 map ab foobar |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
149 call assert_equal('foobar', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
150 call assert_equal('foobar', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
151 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
152 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
153 unmap ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
154 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
155 map abc barfoo |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
156 call assert_equal('barfoo', mapcheck('a')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
157 call assert_equal('barfoo', mapcheck('a', 'n', 0)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
158 call assert_equal('', mapcheck('a', 'n', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
159 call assert_equal('barfoo', mapcheck('abc')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
160 call assert_equal('', mapcheck('ax')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
161 call assert_equal('', mapcheck('b')) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
162 unmap abc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
163 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
164 abbr ab abbrev |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
165 call assert_equal('abbrev', mapcheck('a', 'i', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
166 call assert_equal('', mapcheck('a', 'n', 1)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
167 call assert_equal('', mapcheck('a', 'i', 0)) |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
168 unabbr ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
169 endfunc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
170 |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
171 func Test_range_map() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 " Outside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 inoremap <Char-0x1040> a |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 execute "normal a\u1040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 " Inside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 inoremap <Char-0x103f> b |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 execute "normal a\u103f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 " Inside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 inoremap <Char-0xf03f> c |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 execute "normal a\uf03f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 " Outside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 inoremap <Char-0xf040> d |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 execute "normal a\uf040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 call assert_equal("abcd", getline(1)) |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
186 endfunc |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
187 |
30007
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
188 func One_mapset_test(keys, rhs) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
189 exe 'nnoremap ' .. a:keys .. ' ' .. a:rhs |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
190 let orig = maparg(a:keys, 'n', 0, 1) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
191 call assert_equal(a:keys, orig.lhs) |
30007
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
192 call assert_equal(a:rhs, orig.rhs) |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
193 call assert_equal('n', orig.mode) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
194 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
195 exe 'nunmap ' .. a:keys |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
196 let d = maparg(a:keys, 'n', 0, 1) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
197 call assert_equal({}, d) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
198 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
199 call mapset('n', 0, orig) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
200 let d = maparg(a:keys, 'n', 0, 1) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
201 call assert_equal(a:keys, d.lhs) |
30007
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
202 call assert_equal(a:rhs, d.rhs) |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
203 call assert_equal('n', d.mode) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
204 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
205 exe 'nunmap ' .. a:keys |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
206 endfunc |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
207 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
208 func Test_mapset() |
30007
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
209 call One_mapset_test('K', 'original<CR>') |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
210 call One_mapset_test('<F3>', 'original<CR>') |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
211 call One_mapset_test('<F3>', '<lt>Nop>') |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
212 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
213 " Check <> key conversion |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
214 new |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
215 inoremap K one<Left>x |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
216 call feedkeys("iK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
217 call assert_equal('onxe', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
218 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
219 let orig = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
220 call assert_equal('K', orig.lhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
221 call assert_equal('one<Left>x', orig.rhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
222 call assert_equal('i', orig.mode) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
223 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
224 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
225 let d = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
226 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
227 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
228 call mapset('i', 0, orig) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
229 call feedkeys("SK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
230 call assert_equal('onxe', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
231 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
232 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
233 |
30007
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
234 " Test that <Nop> is restored properly |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
235 inoremap K <Nop> |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
236 call feedkeys("SK\<Esc>", 'xt') |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
237 call assert_equal('', getline(1)) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
238 |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
239 let orig = maparg('K', 'i', 0, 1) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
240 call assert_equal('K', orig.lhs) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
241 call assert_equal('<Nop>', orig.rhs) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
242 call assert_equal('i', orig.mode) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
243 |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
244 inoremap K foo |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
245 call feedkeys("SK\<Esc>", 'xt') |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
246 call assert_equal('foo', getline(1)) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
247 |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
248 call mapset('i', 0, orig) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
249 call feedkeys("SK\<Esc>", 'xt') |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
250 call assert_equal('', getline(1)) |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
251 |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
252 iunmap K |
4123e4bd1708
patch 9.0.0341: mapset() does not restore <Nop> mapping properly
Bram Moolenaar <Bram@vim.org>
parents:
29994
diff
changeset
|
253 |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
254 " Test literal <CR> using a backslash |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
255 let cpo_save = &cpo |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
256 set cpo-=B |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
257 inoremap K one\<CR>two |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
258 call feedkeys("SK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
259 call assert_equal('one<CR>two', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
260 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
261 let orig = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
262 call assert_equal('K', orig.lhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
263 call assert_equal('one\<CR>two', orig.rhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
264 call assert_equal('i', orig.mode) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
265 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
266 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
267 let d = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
268 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
269 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
270 call mapset('i', 0, orig) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
271 call feedkeys("SK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
272 call assert_equal('one<CR>two', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
273 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
274 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
275 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
276 " Test literal <CR> using CTRL-V |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
277 inoremap K one<CR>two |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
278 call feedkeys("SK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
279 call assert_equal('one<CR>two', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
280 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
281 let orig = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
282 call assert_equal('K', orig.lhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
283 call assert_equal("one\x16<CR>two", orig.rhs) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
284 call assert_equal('i', orig.mode) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
285 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
286 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
287 let d = maparg('K', 'i', 0, 1) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
288 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
289 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
290 call mapset('i', 0, orig) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
291 call feedkeys("SK\<Esc>", 'xt') |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
292 call assert_equal('one<CR>two', getline(1)) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
293 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
294 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
295 let &cpo = cpo_save |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
296 bwipe! |
22450
9b09676b9e0e
patch 8.2.1773: crash when calling mapset() with a list as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
297 |
9b09676b9e0e
patch 8.2.1773: crash when calling mapset() with a list as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
298 call assert_fails('call mapset([], v:false, {})', 'E730:') |
29994
86eb4aba16c3
patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents:
28817
diff
changeset
|
299 call assert_fails('call mapset("i", 0, "")', 'E1206:') |
23984
e27b5529dc6a
patch 8.2.2534: missing test coverage
Bram Moolenaar <Bram@vim.org>
parents:
22450
diff
changeset
|
300 call assert_fails('call mapset("i", 0, {})', 'E460:') |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
301 endfunc |
19149
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
302 |
28674
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
303 def Test_mapset_arg1_dir() |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
304 # This test is mostly about get_map_mode_string. |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
305 # Once the code gets past that, it's common with the 3 arg mapset. |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
306 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
307 # GetModes() return list of modes for 'XZ' lhs using maplist. |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
308 # There is one list item per mapping |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
309 def GetModes(abbr: bool = false): list<string> |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
310 return maplist(abbr)->filter((_, m) => m.lhs == 'XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
311 ->mapnew((_, m) => m.mode) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
312 enddef |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
313 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
314 const unmap_cmds = [ 'unmap', 'unmap!', 'tunmap', 'lunmap' ] |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
315 def UnmapAll(lhs: string) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
316 for cmd in unmap_cmds |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
317 try | execute(cmd .. ' ' .. lhs) | catch /E31/ | endtry |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
318 endfor |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
319 enddef |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
320 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
321 var tmap: dict<any> |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
322 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
323 # some mapset(mode, abbr, dict) tests using get_map_mode_str |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
324 map XZ x |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
325 tmap = maplist()->filter((_, m) => m.lhs == 'XZ')[0]->copy() |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
326 # this splits the mapping into 2 mappings |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
327 mapset('ox', false, tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
328 assert_equal(2, len(GetModes())) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
329 mapset('o', false, tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
330 assert_equal(3, len(GetModes())) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
331 # test that '' acts like ' ', and that the 3 mappings become 1 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
332 mapset('', false, tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
333 assert_equal([' '], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
334 # dict's mode/abbr are ignored |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
335 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
336 tmap.mode = '!' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
337 tmap.abbr = true |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
338 mapset('o', false, tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
339 assert_equal(['o'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
340 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
341 # test the 3 arg version handles bad mode string, dict not used |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
342 assert_fails("mapset('vi', false, {})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
343 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
344 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
345 # get the abbreviations out of the way |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
346 abbreviate XZ ZX |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
347 tmap = maplist(true)->filter((_, m) => m.lhs == 'XZ')[0]->copy() |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
348 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
349 abclear |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
350 # 'ic' is the default ab command, shows up as '!' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
351 tmap.mode = 'ic' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
352 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
353 assert_equal(['!'], GetModes(true)) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
354 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
355 abclear |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
356 tmap.mode = 'i' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
357 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
358 assert_equal(['i'], GetModes(true)) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
359 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
360 abclear |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
361 tmap.mode = 'c' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
362 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
363 assert_equal(['c'], GetModes(true)) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
364 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
365 abclear |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
366 tmap.mode = '!' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
367 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
368 assert_equal(['!'], GetModes(true)) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
369 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
370 assert_fails("mapset({mode: ' !', abbr: 1})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
371 assert_fails("mapset({mode: 'cl', abbr: 1})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
372 assert_fails("mapset({mode: 'in', abbr: 1})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
373 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
374 # the map commands |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
375 map XZ x |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
376 tmap = maplist()->filter((_, m) => m.lhs == 'XZ')[0]->copy() |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
377 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
378 # try the combos |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
379 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
380 # 'nxso' is ' ', the unadorned :map |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
381 tmap.mode = 'nxso' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
382 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
383 assert_equal([' '], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
384 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
385 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
386 # 'ic' is '!' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
387 tmap.mode = 'ic' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
388 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
389 assert_equal(['!'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
390 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
391 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
392 # 'xs' is really 'v' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
393 tmap.mode = 'xs' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
394 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
395 assert_equal(['v'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
396 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
397 # try the individual modes |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
398 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
399 tmap.mode = 'n' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
400 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
401 assert_equal(['n'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
402 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
403 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
404 tmap.mode = 'x' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
405 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
406 assert_equal(['x'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
407 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
408 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
409 tmap.mode = 's' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
410 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
411 assert_equal(['s'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
412 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
413 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
414 tmap.mode = 'o' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
415 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
416 assert_equal(['o'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
417 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
418 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
419 tmap.mode = 'i' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
420 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
421 assert_equal(['i'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
422 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
423 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
424 tmap.mode = 'c' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
425 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
426 assert_equal(['c'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
427 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
428 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
429 tmap.mode = 't' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
430 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
431 assert_equal(['t'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
432 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
433 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
434 tmap.mode = 'l' |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
435 mapset(tmap) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
436 assert_equal(['l'], GetModes()) |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
437 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
438 UnmapAll('XZ') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
439 |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
440 # get errors for modes that can't be in one mapping |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
441 assert_fails("mapset({mode: 'nxsoi', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
442 assert_fails("mapset({mode: ' !', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
443 assert_fails("mapset({mode: 'ix', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
444 assert_fails("mapset({mode: 'tl', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
445 assert_fails("mapset({mode: ' l', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
446 assert_fails("mapset({mode: ' t', abbr: 0})", 'E1276:') |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
447 enddef |
38f7a132bba3
patch 8.2.4861: it is not easy to restore saved mappings
Bram Moolenaar <Bram@vim.org>
parents:
28614
diff
changeset
|
448 |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
449 func Check_ctrlb_map(d, check_alt) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
450 call assert_equal('<C-B>', a:d.lhs) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
451 if a:check_alt |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
452 call assert_equal("\x80\xfc\x04B", a:d.lhsraw) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
453 call assert_equal("\x02", a:d.lhsrawalt) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
454 else |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
455 call assert_equal("\x02", a:d.lhsraw) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
456 endif |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
457 endfunc |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
458 |
24529
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
459 func Test_map_local() |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
460 nmap a global |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
461 nmap <buffer>a local |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
462 |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
463 let prev_map_list = split(execute('nmap a'), "\n") |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
464 call assert_match('n\s*a\s*@local', prev_map_list[0]) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
465 call assert_match('n\s*a\s*global', prev_map_list[1]) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
466 |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
467 let mapping = maparg('a', 'n', 0, 1) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
468 call assert_equal(1, mapping.buffer) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
469 let mapping.rhs = 'new_local' |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
470 call mapset('n', 0, mapping) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
471 |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
472 " Check that the global mapping is left untouched. |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
473 let map_list = split(execute('nmap a'), "\n") |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
474 call assert_match('n\s*a\s*@new_local', map_list[0]) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
475 call assert_match('n\s*a\s*global', map_list[1]) |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
476 |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
477 nunmap a |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
478 endfunc |
db2b4e867d06
patch 8.2.2804: setting buffer local mapping with mapset() changes global
Bram Moolenaar <Bram@vim.org>
parents:
23984
diff
changeset
|
479 |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
480 func Test_map_restore() |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
481 " Test restoring map with alternate keycode |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
482 nmap <C-B> back |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
483 let d = maparg('<C-B>', 'n', 0, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
484 call Check_ctrlb_map(d, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
485 let dsimp = maparg("\x02", 'n', 0, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
486 call Check_ctrlb_map(dsimp, 0) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
487 nunmap <C-B> |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
488 call mapset('n', 0, d) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
489 let d = maparg('<C-B>', 'n', 0, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
490 call Check_ctrlb_map(d, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
491 let dsimp = maparg("\x02", 'n', 0, 1) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
492 call Check_ctrlb_map(dsimp, 0) |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
493 |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
494 nunmap <C-B> |
32222
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
495 endfunc |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
496 |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
497 " Test restoring an <SID> mapping |
32222
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
498 func Test_map_restore_sid() |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
499 func RestoreMap() |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
500 const d = maparg('<CR>', 'i', v:false, v:true) |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
501 iunmap <buffer> <CR> |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
502 call mapset('i', v:false, d) |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
503 endfunc |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
504 |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
505 let mapscript =<< trim [CODE] |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
506 inoremap <silent><buffer> <SID>Return <C-R>=42<CR> |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
507 inoremap <script><buffer> <CR> <CR><SID>Return |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
508 [CODE] |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
509 call writefile(mapscript, 'Xmapscript', 'D') |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
510 |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
511 new |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
512 source Xmapscript |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
513 inoremap <buffer> <C-B> <Cmd>call RestoreMap()<CR> |
32758
39b1788b1765
patch 9.0.1698: Test_map_restore_sid fails in GUI
Christian Brabandt <cb@256bit.org>
parents:
32736
diff
changeset
|
514 call feedkeys("i\<CR>\<*C-B>\<CR>", 'xt') |
32736
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
515 call assert_equal(['', '42', '42'], getline(1, '$')) |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
516 |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
517 bwipe! |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
518 delfunc RestoreMap |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
519 endfunc |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
520 |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
521 " Test restoring a mapping with a negative script ID |
161ae1985d81
patch 9.0.1687: mapset() not properly handling script ID
Christian Brabandt <cb@256bit.org>
parents:
32222
diff
changeset
|
522 func Test_map_restore_negative_sid() |
32222
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
523 let after =<< trim [CODE] |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
524 call assert_equal("\tLast set from --cmd argument", |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
525 \ execute('verbose nmap ,n')->trim()->split("\n")[-1]) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
526 let d = maparg(',n', 'n', 0, 1) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
527 nunmap ,n |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
528 call assert_equal('No mapping found', |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
529 \ execute('verbose nmap ,n')->trim()->split("\n")[-1]) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
530 call mapset('n', 0, d) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
531 call assert_equal("\tLast set from --cmd argument", |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
532 \ execute('verbose nmap ,n')->trim()->split("\n")[-1]) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
533 call writefile(v:errors, 'Xresult') |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
534 qall! |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
535 [CODE] |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
536 |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
537 if RunVim([], after, '--clean --cmd "nmap ,n <Nop>"') |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
538 call assert_equal([], readfile('Xresult')) |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
539 endif |
44ba07fe943e
patch 9.0.1442: mapset() does not restore non-script context
Bram Moolenaar <Bram@vim.org>
parents:
31849
diff
changeset
|
540 call delete('Xresult') |
20522
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
541 endfunc |
729853a754ea
patch 8.2.0815: maparg() does not provide enough information for mapset()
Bram Moolenaar <Bram@vim.org>
parents:
20516
diff
changeset
|
542 |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
543 def Test_maplist() |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
544 new |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
545 def ClearMappingsAbbreviations() |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
546 mapclear | nmapclear | vmapclear | xmapclear | smapclear | omapclear |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
547 mapclear! | imapclear | lmapclear | cmapclear | tmapclear |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
548 mapclear <buffer> | nmapclear <buffer> | vmapclear <buffer> |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
549 xmapclear <buffer> | smapclear <buffer> | omapclear <buffer> |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
550 mapclear! <buffer> | imapclear <buffer> | lmapclear <buffer> |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
551 cmapclear <buffer> | tmapclear <buffer> |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
552 abclear | abclear <buffer> |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
553 enddef |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
554 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
555 def AddMaps(new: list<string>, accum: list<string>) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
556 if len(new) > 0 && new[0] != "No mapping found" |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
557 accum->extend(new) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
558 endif |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
559 enddef |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
560 |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
561 ClearMappingsAbbreviations() |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
562 assert_equal(0, len(maplist())) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
563 assert_equal(0, len(maplist(true))) |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
564 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
565 # Set up some mappings. |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
566 map dup bar |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
567 map <buffer> dup bufbar |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
568 map foo<C-V> is<F4>foo |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
569 vnoremap <script> <buffer> <expr> <silent> bar isbar |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
570 tmap baz foo |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
571 omap h w |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
572 lmap i w |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
573 nmap j w |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
574 xmap k w |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
575 smap l w |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
576 map abc <Nop> |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
577 nmap <M-j> x |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
578 nmap <M-Space> y |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
579 # And abbreviations |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
580 abbreviate xy he |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
581 abbreviate xx she |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
582 abbreviate <buffer> x they |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
583 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
584 # Get a list of the mappings with the ':map' commands. |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
585 # Check maplist() return a list of the same size. |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
586 assert_equal(13, len(maplist())) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
587 assert_equal(3, len(maplist(true))) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
588 assert_equal(13, len(maplist(false))) |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
589 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
590 # collect all the current maps using :map commands |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
591 var maps_command: list<string> |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
592 AddMaps(split(execute('map'), '\n'), maps_command) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
593 AddMaps(split(execute('map!'), '\n'), maps_command) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
594 AddMaps(split(execute('tmap'), '\n'), maps_command) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
595 AddMaps(split(execute('lmap'), '\n'), maps_command) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
596 |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
597 # Use maplist to get all the maps |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
598 var maps_maplist = maplist() |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
599 assert_equal(len(maps_command), len(maps_maplist)) |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
600 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
601 # make sure all the mode-lhs are unique, no duplicates |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
602 var map_set: dict<number> |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
603 for d in maps_maplist |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
604 map_set[d.mode .. "-" .. d.lhs .. "-" .. d.buffer] = 0 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
605 endfor |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
606 assert_equal(len(maps_maplist), len(map_set)) |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
607 |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
608 # For everything returned by maplist, should be the same as from maparg. |
30986
360f286b5869
patch 9.0.0828: various typos
Bram Moolenaar <Bram@vim.org>
parents:
30007
diff
changeset
|
609 # Except for "map dup", because maparg returns the <buffer> version |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
610 for d in maps_maplist |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
611 if d.lhs == 'dup' && d.buffer == 0 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
612 continue |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
613 endif |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
614 var d_maparg = maparg(d.lhs, d.mode, false, true) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
615 assert_equal(d_maparg, d) |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
616 endfor |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
617 |
28602
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
618 # Check abbr matches maparg |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
619 for d in maplist(true) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
620 # Note, d.mode is '!', but can't use that with maparg |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
621 var d_maparg = maparg(d.lhs, 'i', true, true) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
622 assert_equal(d_maparg, d) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
623 endfor |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
624 |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
625 ClearMappingsAbbreviations() |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
626 assert_equal(0, len(maplist())) |
398c5b3211f9
patch 8.2.4825: can only get a list of mappings
Bram Moolenaar <Bram@vim.org>
parents:
28592
diff
changeset
|
627 assert_equal(0, len(maplist(true))) |
28592
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
628 enddef |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
629 |
d3c966c0cdf7
patch 8.2.4820: not simple programmatic way to find a specific mapping
Bram Moolenaar <Bram@vim.org>
parents:
27223
diff
changeset
|
630 |
19149
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
631 " vim: shiftwidth=2 sts=2 expandtab |