aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_maparg.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-01 12:27:37 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-01 21:54:18 +0800
commit083865071b52d746de50294a0603bc6dbe20b3ec (patch)
tree9bd9fda27f8dc86963b3c4567502d139afe9b9ed /src/nvim/testdir/test_maparg.vim
parentdb6e93c48df551e2906c9e0f4472f9e54cea3dd9 (diff)
downloadrneovim-083865071b52d746de50294a0603bc6dbe20b3ec.tar.gz
rneovim-083865071b52d746de50294a0603bc6dbe20b3ec.tar.bz2
rneovim-083865071b52d746de50294a0603bc6dbe20b3ec.zip
vim-patch:8.2.0807: cannot easily restore a mapping
Problem: Cannot easily restore a mapping. Solution: Add mapset(). https://github.com/vim/vim/commit/4c9243f9fb708c9010867d3cc8e928f36b58509a Use MapArgument to reduce number of arguments of map_add(). N/A patches for version.c: vim-patch:8.2.0809: build failure with small features Problem: Build failure with small features. (Tony Mechelynck) Solution: Move "expr" inside #ifdef. https://github.com/vim/vim/commit/5a80f8ad5dc0b2cc63400255dcf3c63f6c1a2ef9
Diffstat (limited to 'src/nvim/testdir/test_maparg.vim')
-rw-r--r--src/nvim/testdir/test_maparg.vim51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim
index f9429a8020..ec9af3d825 100644
--- a/src/nvim/testdir/test_maparg.vim
+++ b/src/nvim/testdir/test_maparg.vim
@@ -1,12 +1,12 @@
-" Tests for maparg().
+" Tests for maparg(), mapcheck() and mapset().
" Also test utf8 map with a 0x80 byte.
" Also test mapcheck()
-function s:SID()
+func s:SID()
return str2nr(matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$'))
-endfun
+endfunc
-function Test_maparg()
+funct Test_maparg()
new
set cpo-=<
set encoding=utf8
@@ -17,24 +17,24 @@ function Test_maparg()
vnoremap <script> <buffer> <expr> <silent> bar isbar
call assert_equal("is<F4>foo", maparg('foo<C-V>'))
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo<C-V>',
- \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
- \ 'rhs': 'is<F4>foo', 'buffer': 0},
- \ maparg('foo<C-V>', '', 0, 1))
+ \ 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1,
+ \ 'simplified': 1, 'rhs': 'is<F4>foo', 'buffer': 0},
+ \ maparg('foo<C-V>', '', 0, 1))
call assert_equal({'silent': 1, 'noremap': 1, 'script': 1, 'lhs': 'bar', 'mode': 'v',
\ 'nowait': 0, 'expr': 1, 'sid': sid, 'lnum': lnum + 2,
- \ 'rhs': 'isbar', 'buffer': 1},
+ \ 'simplified': 0, 'rhs': 'isbar', 'buffer': 1},
\ 'bar'->maparg('', 0, 1))
let lnum = expand('<sflnum>')
map <buffer> <nowait> foo bar
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'foo', 'mode': ' ',
\ 'nowait': 1, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'bar',
- \ 'buffer': 1},
+ \ 'simplified': 0, 'buffer': 1},
\ maparg('foo', '', 0, 1))
let lnum = expand('<sflnum>')
tmap baz foo
call assert_equal({'silent': 0, 'noremap': 0, 'script': 0, 'lhs': 'baz', 'mode': 't',
\ 'nowait': 0, 'expr': 0, 'sid': sid, 'lnum': lnum + 1, 'rhs': 'foo',
- \ 'buffer': 0},
+ \ 'simplified': 0, 'buffer': 0},
\ maparg('baz', 't', 0, 1))
map abc x<char-114>x
@@ -89,7 +89,7 @@ function Test_maparg()
let d = maparg('esc', 'i', 1, 1)
call assert_equal(['esc', "\<C-V>\<C-V>\<Esc>", '!'], [d.lhs, d.rhs, d.mode])
abclear
-endfunction
+endfunc
func Test_mapcheck()
call assert_equal('', mapcheck('a'))
@@ -130,7 +130,7 @@ func Test_mapcheck()
unabbr ab
endfunc
-function Test_range_map()
+func Test_range_map()
new
" Outside of the range, minimum
inoremap <Char-0x1040> a
@@ -145,6 +145,31 @@ function Test_range_map()
inoremap <Char-0xf040> d
execute "normal a\uf040\<Esc>"
call assert_equal("abcd", getline(1))
-endfunction
+endfunc
+
+func One_mapset_test(keys)
+ exe 'nnoremap ' .. a:keys .. ' original<CR>'
+ let orig = maparg(a:keys, 'n', 0, 1)
+ call assert_equal(a:keys, orig.lhs)
+ call assert_equal('original<CR>', orig.rhs)
+ call assert_equal('n', orig.mode)
+
+ exe 'nunmap ' .. a:keys
+ let d = maparg(a:keys, 'n', 0, 1)
+ call assert_equal({}, d)
+
+ call mapset('n', 0, orig)
+ let d = maparg(a:keys, 'n', 0, 1)
+ call assert_equal(a:keys, d.lhs)
+ call assert_equal('original<CR>', d.rhs)
+ call assert_equal('n', d.mode)
+
+ exe 'nunmap ' .. a:keys
+endfunc
+
+func Test_mapset()
+ call One_mapset_test('K')
+ call One_mapset_test('<F3>')
+endfunc
" vim: shiftwidth=2 sts=2 expandtab