annotate src/testdir/test_maparg.vim @ 17522:e17cbc3e545d v8.1.1759

patch 8.1.1759: no mode char for terminal mapping from maparg() commit https://github.com/vim/vim/commit/14371ed69778107654e39268d0d90982e53ad6e0 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 27 21:05:21 2019 +0200 patch 8.1.1759: no mode char for terminal mapping from maparg() Problem: No mode char for terminal mapping from maparg(). Solution: Check for TERMINAL mode. (closes https://github.com/vim/vim/issues/4735)
author Bram Moolenaar <Bram@vim.org>
date Sat, 27 Jul 2019 21:15:05 +0200
parents 2dcaa860e3fc
children 0cdb6ac20748
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for maparg().
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
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 function s:SID()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 endfun
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 function Test_maparg()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 new
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 set cpo-=<
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 set encoding=utf8
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " 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
13 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
14 let lnum = expand('<sflnum>')
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 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
16 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
17 call assert_equal("is<F4>foo", maparg('foo<C-V>'))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call assert_equal({'silent': 0, 'noremap': 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
19 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
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 \ 'rhs': 'is<F4>foo', 'buffer': 0},
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 13986
diff changeset
21 \ maparg('foo<C-V>', '', 0, 1))
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call assert_equal({'silent': 1, 'noremap': 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
23 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
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 \ 'rhs': 'isbar', 'buffer': 1},
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 \ maparg('bar', '', 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
26 let lnum = expand('<sflnum>')
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 map <buffer> <nowait> foo bar
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call assert_equal({'silent': 0, 'noremap': 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
29 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
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 \ 'buffer': 1},
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 \ 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
32 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
33 tmap baz foo
e17cbc3e545d patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
34 call assert_equal({'silent': 0, 'noremap': 0, 'lhs': 'baz', 'mode': 't',
e17cbc3e545d patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
35 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
e17cbc3e545d patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
36 \ 'buffer': 0},
e17cbc3e545d patch 8.1.1759: no mode char for terminal mapping from maparg()
Bram Moolenaar <Bram@vim.org>
parents: 15607
diff changeset
37 \ maparg('baz', 't', 0, 1))
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 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
40 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
41 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
42 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
43
4a41a169e5ea patch 8.1.0011: maparg() and mapcheck() confuse empty and non-existing
Christian Brabandt <cb@256bit.org>
parents: 11651
diff changeset
44 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
45 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
46 unmap abc
11651
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 endfunction
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 function Test_range_map()
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 new
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " Outside of the range, minimum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 inoremap <Char-0x1040> a
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 execute "normal a\u1040\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 " Inside of the range, minimum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 inoremap <Char-0x103f> b
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 execute "normal a\u103f\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Inside of the range, maximum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 inoremap <Char-0xf03f> c
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 execute "normal a\uf03f\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 " Outside of the range, maximum
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 inoremap <Char-0xf040> d
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 execute "normal a\uf040\<Esc>"
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 call assert_equal("abcd", getline(1))
140d51d5b5c3 patch 8.0.0708: some tests are old style
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endfunction