From de2232878fb95bdb84f8219c7cf1d7f2c2828086 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 30 Apr 2022 14:00:53 +0800 Subject: vim-patch:8.2.0144: some mapping code is not fully tested (#18313) Problem: Some mapping code is not fully tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes vim/vim#5519) https://github.com/vim/vim/commit/c2a60ae10e7badad9186de59a9994fc8c9f539e0 --- src/nvim/testdir/test_langmap.vim | 27 ++++ src/nvim/testdir/test_maparg.vim | 25 ++++ src/nvim/testdir/test_mapping.vim | 250 +++++++++++++++++++++++++++++++++++++- 3 files changed, 301 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_langmap.vim b/src/nvim/testdir/test_langmap.vim index 066c3bf2bd..eca8a95564 100644 --- a/src/nvim/testdir/test_langmap.vim +++ b/src/nvim/testdir/test_langmap.vim @@ -20,5 +20,32 @@ func Test_langmap() silent! call feedkeys("gg0}%}\}^\00", 'tx') call assert_equal('a}^de', getline(1)) + " Error cases + call assert_fails('set langmap=aA,b', 'E357:') + call assert_fails('set langmap=z;y;y;z', 'E358:') + + " Map character > 256 + enew! + set langmap=āx,ăl,āx + call setline(1, ['abcde']) + call feedkeys('gg2lā', 'tx') + call assert_equal('abde', getline(1)) + + " special characters in langmap + enew! + call setline(1, ['Hello World']) + set langmap=\\;\\,,\\,\\; + call feedkeys('ggfo,', 'tx') + call assert_equal(8, col('.')) + call feedkeys(';', 'tx') + call assert_equal(5, col('.')) + set langmap& + set langmap=\\;\\,;\\,\\; + call feedkeys('ggfo,', 'tx') + call assert_equal(8, col('.')) + call feedkeys(';', 'tx') + call assert_equal(5, col('.')) + + set langmap& quit! endfunc diff --git a/src/nvim/testdir/test_maparg.vim b/src/nvim/testdir/test_maparg.vim index 5b082198cf..cebde89996 100644 --- a/src/nvim/testdir/test_maparg.vim +++ b/src/nvim/testdir/test_maparg.vim @@ -47,9 +47,34 @@ function Test_maparg() call assert_equal(['{', 'w', 'o'], [d.lhs, d.rhs, d.mode]) ounmap { + lmap { w + let d = maparg('{', 'l', 0, 1) + call assert_equal(['{', 'w', 'l'], [d.lhs, d.rhs, d.mode]) + lunmap { + + nmap { w + let d = maparg('{', 'n', 0, 1) + call assert_equal(['{', 'w', 'n'], [d.lhs, d.rhs, d.mode]) + nunmap { + + xmap { w + let d = maparg('{', 'x', 0, 1) + call assert_equal(['{', 'w', 'x'], [d.lhs, d.rhs, d.mode]) + xunmap { + + smap { w + let d = maparg('{', 's', 0, 1) + call assert_equal(['{', 'w', 's'], [d.lhs, d.rhs, d.mode]) + sunmap { + map abc call assert_equal("", maparg('abc')) unmap abc + + call feedkeys(":abbr esc \\\\\\\", "xt") + let d = maparg('esc', 'i', 1, 1) + call assert_equal(['esc', "\\\", '!'], [d.lhs, d.rhs, d.mode]) + abclear endfunction func Test_mapcheck() diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 6bb8d82021..1da3b71a32 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -449,6 +449,22 @@ func Test_list_mappings() call assert_equal(['i * ShiftSlash'], execute('imap')->trim()->split("\n")) iunmap call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n")) + + " List global, buffer local and script local mappings + nmap ,f /^\k\+ ( + nmap ,f /^\k\+ ( + nmap