From 5c72640bc2b60a018ccfcf18bca809b635f250f6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 1 Aug 2022 14:00:57 +0800 Subject: vim-patch:8.2.0812: mapset() does not properly handle <> notation Problem: mapset() does not properly handle <> notation. Solution: Convert <> codes. (closes vim/vim#6116) https://github.com/vim/vim/commit/c94c1467b9b86156a6b7c8d3e41ff01c13d2be07 --- src/nvim/testdir/test_maparg.vim | 69 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim index ec9af3d825..6fea66b7c6 100644 --- a/src/nvim/testdir/test_maparg.vim +++ b/src/nvim/testdir/test_maparg.vim @@ -6,7 +6,7 @@ func s:SID() return str2nr(matchstr(expand(''), '\zs\d\+\ze_SID$')) endfunc -funct Test_maparg() +func Test_maparg() new set cpo-=< set encoding=utf8 @@ -170,6 +170,73 @@ endfunc func Test_mapset() call One_mapset_test('K') call One_mapset_test('') + + " Check <> key conversion + new + inoremap K onex + call feedkeys("iK\", 'xt') + call assert_equal('onxe', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal('onex', orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onxe', getline(1)) + + iunmap K + + " Test literal using a backslash + let cpo_save = &cpo + set cpo-=B + inoremap K one\two + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal('one\two', orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + iunmap K + let &cpo = cpo_save + + " Test literal using CTRL-V + inoremap K onetwo + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + let orig = maparg('K', 'i', 0, 1) + call assert_equal('K', orig.lhs) + call assert_equal("one\x16two", orig.rhs) + call assert_equal('i', orig.mode) + + iunmap K + let d = maparg('K', 'i', 0, 1) + call assert_equal({}, d) + + call mapset('i', 0, orig) + call feedkeys("SK\", 'xt') + call assert_equal('onetwo', getline(1)) + + iunmap K + let &cpo = cpo_save + + bwipe! endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit