diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2022-05-03 06:11:22 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2022-05-03 06:21:50 +0800 |
| commit | 27149e0071c3fa38c81526f63a997bedfd6e2be8 (patch) | |
| tree | 8d819a934bd5c11c7947ff06bea23a609723d078 /src/nvim/testdir | |
| parent | ddf7bb24f98b468d2bc6c16c6f300570fc6530f5 (diff) | |
| download | rneovim-27149e0071c3fa38c81526f63a997bedfd6e2be8.tar.gz rneovim-27149e0071c3fa38c81526f63a997bedfd6e2be8.tar.bz2 rneovim-27149e0071c3fa38c81526f63a997bedfd6e2be8.zip | |
vim-patch:8.2.4858: K_SPECIAL may be escaped twice
Problem: K_SPECIAL may be escaped twice.
Solution: Avoid double escaping. (closes vim/vim#10340)
https://github.com/vim/vim/commit/db08887f24d20be11d184ce321bc0890613e42bd
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_eval_stuff.vim | 22 | ||||
| -rw-r--r-- | src/nvim/testdir/test_feedkeys.vim | 11 | ||||
| -rw-r--r-- | src/nvim/testdir/test_functions.vim | 4 | ||||
| -rw-r--r-- | src/nvim/testdir/test_mapping.vim | 15 |
4 files changed, 50 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_eval_stuff.vim b/src/nvim/testdir/test_eval_stuff.vim index 95eccde35c..811c6c946d 100644 --- a/src/nvim/testdir/test_eval_stuff.vim +++ b/src/nvim/testdir/test_eval_stuff.vim @@ -320,4 +320,26 @@ func Test_curly_assignment() unlet g:gvar endfunc +" K_SPECIAL in the modified character used be escaped, which causes +" double-escaping with feedkeys() or as the return value of an <expr> mapping, +" and doesn't match what getchar() returns, +func Test_modified_char_no_escape_special() + nnoremap <M-…> <Cmd>let g:got_m_ellipsis += 1<CR> + call feedkeys("\<M-…>", 't') + call assert_equal("\<M-…>", getchar()) + let g:got_m_ellipsis = 0 + call feedkeys("\<M-…>", 'xt') + call assert_equal(1, g:got_m_ellipsis) + func Func() + return "\<M-…>" + endfunc + nmap <expr> <F2> Func() + call feedkeys("\<F2>", 'xt') + call assert_equal(2, g:got_m_ellipsis) + delfunc Func + nunmap <F2> + unlet g:got_m_ellipsis + nunmap <M-…> +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_feedkeys.vim b/src/nvim/testdir/test_feedkeys.vim index f343b0174c..fb64711863 100644 --- a/src/nvim/testdir/test_feedkeys.vim +++ b/src/nvim/testdir/test_feedkeys.vim @@ -23,4 +23,15 @@ func Test_feedkeys_with_abbreviation() iunabbrev trigger endfunc +func Test_feedkeys_escape_special() + nnoremap … <Cmd>let g:got_ellipsis += 1<CR> + call feedkeys('…', 't') + call assert_equal('…', getcharstr()) + let g:got_ellipsis = 0 + call feedkeys('…', 'xt') + call assert_equal(1, g:got_ellipsis) + unlet g:got_ellipsis + nunmap … +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index f8be250f73..87606f17b8 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1751,8 +1751,8 @@ func Test_nr2char() call assert_equal('a', nr2char(97, 1)) call assert_equal('a', nr2char(97, 0)) - call assert_equal("\x80\xfc\b\xf4\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x100000) .. '>"')) - call assert_equal("\x80\xfc\b\xfd\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX\x80\xfeX", eval('"\<M-' .. nr2char(0x40000000) .. '>"')) + call assert_equal("\x80\xfc\b" .. nr2char(0x100000), eval('"\<M-' .. nr2char(0x100000) .. '>"')) + call assert_equal("\x80\xfc\b" .. nr2char(0x40000000), eval('"\<M-' .. nr2char(0x40000000) .. '>"')) endfunc " Test for getcurpos() and setpos() diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 1da3b71a32..752b1700d0 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -1025,4 +1025,19 @@ func Test_unmap_simplifiable() unmap <C-I> endfunc +func Test_expr_map_escape_special() + nnoremap … <Cmd>let g:got_ellipsis += 1<CR> + func Func() + return '…' + endfunc + nmap <expr> <F2> Func() + let g:got_ellipsis = 0 + call feedkeys("\<F2>", 'xt') + call assert_equal(1, g:got_ellipsis) + delfunc Func + nunmap <F2> + unlet g:got_ellipsis + nunmap … +endfunc + " vim: shiftwidth=2 sts=2 expandtab |