feat(mappings): allow special keys and modifiers in <Cmd> mapping

This commit is contained in:
zeertzjq
2022-04-29 20:50:14 +08:00
parent 8c548c9e54
commit 98f62a2cfa
3 changed files with 44 additions and 23 deletions

View File

@@ -93,19 +93,6 @@ describe('mappings with <Cmd>', function()
{2:E5521: <Cmd> mapping must end with <CR> before second <Cmd>} |
]])
command('noremap <F3> <Cmd><F3>let x = 2<cr>')
feed('<F3>')
screen:expect([[
^some short lines |
of test text |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{2:E5522: <Cmd> mapping must not include <F3> key} |
]])
command('noremap <F3> <Cmd>let x = 3')
feed('<F3>')
screen:expect([[
@@ -121,6 +108,34 @@ describe('mappings with <Cmd>', function()
eq(0, eval('x'))
end)
it('allows special keys and modifiers', function()
command('noremap <F3> <Cmd>normal! <Down><CR>')
feed('<F3>')
screen:expect([[
some short lines |
^of test text |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
command('noremap <F3> <Cmd>normal! <C-Right><CR>')
feed('<F3>')
screen:expect([[
some short lines |
of ^test text |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]])
end)
it('works in various modes and sees correct `mode()` value', function()
-- normal mode
feed('<F3>')