Mercurial > vim
comparison src/testdir/test_maparg.vim @ 20522:729853a754ea v8.2.0815
patch 8.2.0815: maparg() does not provide enough information for mapset()
Commit: https://github.com/vim/vim/commit/9c65253fe702ea010afec11aa971acd542c35de2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 24 13:10:18 2020 +0200
patch 8.2.0815: maparg() does not provide enough information for mapset()
Problem: maparg() does not provide enough information for mapset().
Solution: Add "lhsraw" and "lhsrawalt" items. Drop "simplified"
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 24 May 2020 13:15:04 +0200 |
parents | d9e3fdf26cb9 |
children | f27187782dc6 |
comparison
equal
deleted
inserted
replaced
20521:fb1d6f728a72 | 20522:729853a754ea |
---|---|
15 let lnum = expand('<sflnum>') | 15 let lnum = expand('<sflnum>') |
16 map foo<C-V> is<F4>foo | 16 map foo<C-V> is<F4>foo |
17 vnoremap <script> <buffer> <expr> <silent> bar isbar | 17 vnoremap <script> <buffer> <expr> <silent> bar isbar |
18 call assert_equal("is<F4>foo", maparg('foo<C-V>')) | 18 call assert_equal("is<F4>foo", maparg('foo<C-V>')) |
19 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>', | 19 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>', |
20 \ 'lhsraw': "foo\x80\xfc\x04V", 'lhsrawalt': "foo\x16", | |
20 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, | 21 \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, |
21 \ 'simplified': 1, 'rhs': 'is<F4>foo', 'buffer': 0}, | 22 \ 'rhs': 'is<F4>foo', 'buffer': 0}, |
22 \ maparg('foo<C-V>', '', 0, 1)) | 23 \ maparg('foo<C-V>', '', 0, 1)) |
23 call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v', | 24 call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', |
25 \ 'lhsraw': 'bar', 'mode': 'v', | |
24 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, | 26 \ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2, |
25 \ 'simplified': 0, 'rhs': 'isbar', 'buffer': 1}, | 27 \ 'rhs': 'isbar', 'buffer': 1}, |
26 \ 'bar'->maparg('', 0, 1)) | 28 \ 'bar'->maparg('', 0, 1)) |
27 let lnum = expand('<sflnum>') | 29 let lnum = expand('<sflnum>') |
28 map <buffer> <nowait> foo bar | 30 map <buffer> <nowait> foo bar |
29 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ', | 31 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', |
32 \ 'lhsraw': 'foo', 'mode': ' ', | |
30 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', | 33 \ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar', |
31 \ 'simplified': 0, 'buffer': 1}, | 34 \ 'buffer': 1}, |
32 \ maparg('foo', '', 0, 1)) | 35 \ maparg('foo', '', 0, 1)) |
33 let lnum = expand('<sflnum>') | 36 let lnum = expand('<sflnum>') |
34 tmap baz foo | 37 tmap baz foo |
35 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't', | 38 call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', |
39 \ 'lhsraw': 'baz', 'mode': 't', | |
36 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo', | 40 \ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo', |
37 \ 'simplified': 0, 'buffer': 0}, | 41 \ 'buffer': 0}, |
38 \ maparg('baz', 't', 0, 1)) | 42 \ maparg('baz', 't', 0, 1)) |
39 | 43 |
40 map abc x<char-114>x | 44 map abc x<char-114>x |
41 call assert_equal("xrx", maparg('abc')) | 45 call assert_equal("xrx", maparg('abc')) |
42 map abc y<S-char-114>y | 46 map abc y<S-char-114>y |
197 call mapset('i', 0, orig) | 201 call mapset('i', 0, orig) |
198 call feedkeys("SK\<Esc>", 'xt') | 202 call feedkeys("SK\<Esc>", 'xt') |
199 call assert_equal('one<CR>two', getline(1)) | 203 call assert_equal('one<CR>two', getline(1)) |
200 | 204 |
201 iunmap K | 205 iunmap K |
202 let &cpo = cpo_save | |
203 | 206 |
204 " Test literal <CR> using CTRL-V | 207 " Test literal <CR> using CTRL-V |
205 inoremap K one<CR>two | 208 inoremap K one<CR>two |
206 call feedkeys("SK\<Esc>", 'xt') | 209 call feedkeys("SK\<Esc>", 'xt') |
207 call assert_equal('one<CR>two', getline(1)) | 210 call assert_equal('one<CR>two', getline(1)) |
219 call feedkeys("SK\<Esc>", 'xt') | 222 call feedkeys("SK\<Esc>", 'xt') |
220 call assert_equal('one<CR>two', getline(1)) | 223 call assert_equal('one<CR>two', getline(1)) |
221 | 224 |
222 iunmap K | 225 iunmap K |
223 let &cpo = cpo_save | 226 let &cpo = cpo_save |
224 | |
225 bwipe! | 227 bwipe! |
226 endfunc | 228 endfunc |
227 | 229 |
230 func Check_ctrlb_map(d, check_alt) | |
231 call assert_equal('<C-B>', a:d.lhs) | |
232 if a:check_alt | |
233 call assert_equal("\x80\xfc\x04B", a:d.lhsraw) | |
234 call assert_equal("\x02", a:d.lhsrawalt) | |
235 else | |
236 call assert_equal("\x02", a:d.lhsraw) | |
237 endif | |
238 endfunc | |
239 | |
240 func Test_map_restore() | |
241 " Test restoring map with alternate keycode | |
242 nmap <C-B> back | |
243 let d = maparg('<C-B>', 'n', 0, 1) | |
244 call Check_ctrlb_map(d, 1) | |
245 let dsimp = maparg("\x02", 'n', 0, 1) | |
246 call Check_ctrlb_map(dsimp, 0) | |
247 nunmap <C-B> | |
248 call mapset('n', 0, d) | |
249 let d = maparg('<C-B>', 'n', 0, 1) | |
250 call Check_ctrlb_map(d, 1) | |
251 let dsimp = maparg("\x02", 'n', 0, 1) | |
252 call Check_ctrlb_map(dsimp, 0) | |
253 | |
254 nunmap <C-B> | |
255 | |
256 endfunc | |
257 | |
228 " vim: shiftwidth=2 sts=2 expandtab | 258 " vim: shiftwidth=2 sts=2 expandtab |