Mercurial > vim
annotate src/testdir/test_maparg.vim @ 20516:d9e3fdf26cb9 v8.2.0812
patch 8.2.0812: mapset() does not properly handle <> notation
Commit: https://github.com/vim/vim/commit/c94c1467b9b86156a6b7c8d3e41ff01c13d2be07
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 22 20:01:06 2020 +0200
patch 8.2.0812: mapset() does not properly handle <> notation
Problem: mapset() does not properly handle <> notation.
Solution: Convert <> codes. (closes https://github.com/vim/vim/issues/6116)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 22 May 2020 20:15:03 +0200 |
parents | aee0b72ca6d6 |
children | 729853a754ea |
rev | line source |
---|---|
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
1 " Tests for maparg(), mapcheck() and mapset(). |
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. |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
3 " Also test mapcheck() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
5 func s:SID() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 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
|
7 endfunc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
9 func Test_maparg() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 set cpo-=< |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 set encoding=utf8 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " 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
|
14 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
|
15 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 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
|
17 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
|
18 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
|
19 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>', |
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
|
20 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
21 \ 'simplified': 1, 'rhs': 'is<F4>foo', 'buffer': 0}, |
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
|
22 \ maparg('foo<C-V>', '', 0, 1)) |
19870
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19170
diff
changeset
|
23 call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v', |
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
|
24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
25 \ 'simplified': 0, 'rhs': 'isbar', 'buffer': 1}, |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
26 \ '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
|
27 let lnum = expand('<sflnum>') |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 map <buffer> <nowait> foo bar |
19870
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19170
diff
changeset
|
29 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ', |
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
|
30 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
31 \ 'simplified': 0, 'buffer': 1}, |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 \ 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
|
33 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
|
34 tmap baz foo |
19870
658248b68f7c
patch 8.2.0491: cannot recognize a <script> mapping using maparg()
Bram Moolenaar <Bram@vim.org>
parents:
19170
diff
changeset
|
35 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't', |
17522
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
36 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo', |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
37 \ 'simplified': 0, 'buffer': 0}, |
17522
e17cbc3e545d
patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
38 \ maparg('baz', 't', 0, 1)) |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 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
|
41 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
|
42 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
|
43 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
|
44 |
19149
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
45 omap { w |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
46 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
|
47 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
|
48 ounmap { |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
49 |
19170
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
50 lmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
51 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
|
52 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
|
53 lunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
54 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
55 nmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
56 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
|
57 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
|
58 nunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
59 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
60 xmap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
61 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
|
62 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
|
63 xunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
64 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
65 smap { w |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
66 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
|
67 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
|
68 sunmap { |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
69 |
13986
4a41a169e5ea
patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents:
11651
diff
changeset
|
70 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
|
71 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
|
72 unmap abc |
19170
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
73 |
ad40333f2ec0
patch 8.2.0144: some mapping code is not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
19149
diff
changeset
|
74 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
|
75 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
|
76 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
|
77 abclear |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
78 endfunc |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
17930
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 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
|
94 unmap a |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
95 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 unmap ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
102 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 unmap abc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
111 |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 unabbr ab |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
117 endfunc |
0cdb6ac20748
patch 8.1.1961: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17522
diff
changeset
|
118 |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
119 func Test_range_map() |
11651
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 new |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 " Outside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 inoremap <Char-0x1040> a |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 execute "normal a\u1040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 " Inside of the range, minimum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 inoremap <Char-0x103f> b |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 execute "normal a\u103f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 " Inside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 inoremap <Char-0xf03f> c |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
129 execute "normal a\uf03f\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 " Outside of the range, maximum |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 inoremap <Char-0xf040> d |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 execute "normal a\uf040\<Esc>" |
140d51d5b5c3
patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 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
|
134 endfunc |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
135 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
136 func One_mapset_test(keys) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
137 exe 'nnoremap ' .. a:keys .. ' original<CR>' |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
138 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
|
139 call assert_equal(a:keys, orig.lhs) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
140 call assert_equal('original<CR>', orig.rhs) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
141 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
|
142 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
143 exe 'nunmap ' .. a:keys |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
144 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
|
145 call assert_equal({}, d) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
146 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
147 call mapset('n', 0, orig) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
148 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
|
149 call assert_equal(a:keys, d.lhs) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
150 call assert_equal('original<CR>', d.rhs) |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
151 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
|
152 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
153 exe 'nunmap ' .. a:keys |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
154 endfunc |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
155 |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
156 func Test_mapset() |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
157 call One_mapset_test('K') |
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
158 call One_mapset_test('<F3>') |
20516
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
159 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
160 " Check <> key conversion |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
161 new |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
166 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
|
167 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
|
168 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
|
169 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
|
170 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
171 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
172 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
|
173 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
174 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
179 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
180 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
181 " 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
|
182 let cpo_save = &cpo |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
183 set cpo-=B |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 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
|
192 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
193 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
194 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
|
195 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
196 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
201 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
202 let &cpo = cpo_save |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
203 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
204 " 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
|
205 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
|
206 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
|
207 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
|
208 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 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
|
213 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
214 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
215 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
|
216 call assert_equal({}, d) |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
217 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
218 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
|
219 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
|
220 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
|
221 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
222 iunmap K |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
223 let &cpo = cpo_save |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
224 |
d9e3fdf26cb9
patch 8.2.0812: mapset() does not properly handle <> notation
Bram Moolenaar <Bram@vim.org>
parents:
20506
diff
changeset
|
225 bwipe! |
20506
aee0b72ca6d6
patch 8.2.0807: cannot easily restore a mapping
Bram Moolenaar <Bram@vim.org>
parents:
19870
diff
changeset
|
226 endfunc |
19149
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
227 |
643c6c3c0da4
patch 8.2.0134: some map functionality not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
17930
diff
changeset
|
228 " vim: shiftwidth=2 sts=2 expandtab |