Mercurial > vim
comparison src/testdir/test_mapping.vim @ 9925:3fba3e8326a7 v7.4.2236
commit https://github.com/vim/vim/commit/920694c1b60fac8017b8909efcc24f189804a9bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 21 17:45:02 2016 +0200
patch 7.4.2236
Problem: The 'langnoremap' option leads to double negatives. And it does
not work for the last character of a mapping.
Solution: Add 'langremap' with the opposite value. Keep 'langnoremap' for
backwards compatibility. Make it work for the last character of a
mapping. Make the test work.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 21 Aug 2016 18:00:07 +0200 |
parents | 989d44d35a66 |
children | 09c7df6f8dd3 |
comparison
equal
deleted
inserted
replaced
9924:cb0cb5358209 | 9925:3fba3e8326a7 |
---|---|
33 vunmap <c-c> | 33 vunmap <c-c> |
34 set nomodified | 34 set nomodified |
35 endfunc | 35 endfunc |
36 | 36 |
37 func Test_map_langmap() | 37 func Test_map_langmap() |
38 " langmap should not get remapped in insert mode | 38 if !has('langmap') |
39 inoremap { FAIL_ilangmap | 39 return |
40 set langmap=+{ langnoremap | 40 endif |
41 | |
42 " check langmap applies in normal mode | |
43 set langmap=+- nolangremap | |
44 new | |
45 call setline(1, ['a', 'b', 'c']) | |
46 2 | |
47 call assert_equal('b', getline('.')) | |
48 call feedkeys("+", "xt") | |
49 call assert_equal('a', getline('.')) | |
50 | |
51 " check no remapping | |
52 map x + | |
53 2 | |
54 call feedkeys("x", "xt") | |
55 call assert_equal('c', getline('.')) | |
56 | |
57 " check with remapping | |
58 set langremap | |
59 2 | |
60 call feedkeys("x", "xt") | |
61 call assert_equal('a', getline('.')) | |
62 | |
63 unmap x | |
64 bwipe! | |
65 | |
66 " 'langnoremap' follows 'langremap' and vise versa | |
67 set langremap | |
68 set langnoremap | |
69 call assert_equal(0, &langremap) | |
70 set langremap | |
71 call assert_equal(0, &langnoremap) | |
72 set nolangremap | |
73 call assert_equal(1, &langnoremap) | |
74 | |
75 " langmap should not apply in insert mode, 'langremap' doesn't matter | |
76 set langmap=+{ nolangremap | |
77 call feedkeys("Go+\<Esc>", "xt") | |
78 call assert_equal('+', getline('$')) | |
79 set langmap=+{ langremap | |
41 call feedkeys("Go+\<Esc>", "xt") | 80 call feedkeys("Go+\<Esc>", "xt") |
42 call assert_equal('+', getline('$')) | 81 call assert_equal('+', getline('$')) |
43 | 82 |
44 " Insert-mode expr mapping with langmap | 83 " langmap used for register name in insert mode. |
45 inoremap <expr> { "FAIL_iexplangmap" | 84 call setreg('a', 'aaaa') |
46 call feedkeys("Go+\<Esc>", "xt") | 85 call setreg('b', 'bbbb') |
47 call assert_equal('+', getline('$')) | 86 call setreg('c', 'cccc') |
48 iunmap <expr> { | 87 set langmap=ab langremap |
49 | 88 call feedkeys("Go\<C-R>a\<Esc>", "xt") |
50 " langmap should not get remapped in Command-line mode | 89 call assert_equal('bbbb', getline('$')) |
51 cnoremap { FAIL_clangmap | 90 call feedkeys("Go\<C-R>\<C-R>a\<Esc>", "xt") |
91 call assert_equal('bbbb', getline('$')) | |
92 " mapping does not apply | |
93 imap c a | |
94 call feedkeys("Go\<C-R>c\<Esc>", "xt") | |
95 call assert_equal('cccc', getline('$')) | |
96 imap a c | |
97 call feedkeys("Go\<C-R>a\<Esc>", "xt") | |
98 call assert_equal('bbbb', getline('$')) | |
99 | |
100 " langmap should not apply in Command-line mode | |
101 set langmap=+{ nolangremap | |
52 call feedkeys(":call append(line('$'), '+')\<CR>", "xt") | 102 call feedkeys(":call append(line('$'), '+')\<CR>", "xt") |
53 call assert_equal('+', getline('$')) | 103 call assert_equal('+', getline('$')) |
54 cunmap { | |
55 | 104 |
56 " Command-line mode expr mapping with langmap | |
57 cnoremap <expr> { "FAIL_cexplangmap" | |
58 call feedkeys(":call append(line('$'), '+')\<CR>", "xt") | |
59 call assert_equal('+', getline('$')) | |
60 cunmap { | |
61 set nomodified | 105 set nomodified |
62 endfunc | 106 endfunc |
63 | 107 |
64 func Test_map_feedkeys() | 108 func Test_map_feedkeys() |
65 " issue #212 (feedkeys insert mapping at current position) | 109 " issue #212 (feedkeys insert mapping at current position) |