From 98f62a2cfa98363217fdfcf96b6c636e91dba84d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 29 Apr 2022 20:50:14 +0800 Subject: feat(mappings): allow special keys and modifiers in mapping --- test/functional/ex_cmds/cmd_map_spec.lua | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'test/functional') diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua index 64cf53dfa9..dbbfadabd8 100644 --- a/test/functional/ex_cmds/cmd_map_spec.lua +++ b/test/functional/ex_cmds/cmd_map_spec.lua @@ -93,7 +93,7 @@ describe('mappings with ', function() {2:E5521: mapping must end with before second } | ]]) - command('noremap let x = 2') + command('noremap let x = 3') feed('') screen:expect([[ ^some short lines | @@ -103,22 +103,37 @@ describe('mappings with ', function() {1:~ }| {1:~ }| {1:~ }| - {2:E5522: mapping must not include key} | + {2:E5520: mapping must end with } | ]]) + eq(0, eval('x')) + end) - command('noremap let x = 3') + it('allows special keys and modifiers', function() + command('noremap normal! ') feed('') screen:expect([[ - ^some short lines | - of test text | + some short lines | + ^of test text | {1:~ }| {1:~ }| {1:~ }| {1:~ }| {1:~ }| - {2:E5520: mapping must end with } | + | + ]]) + + command('noremap normal! ') + feed('') + screen:expect([[ + some short lines | + of ^test text | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | ]]) - eq(0, eval('x')) end) it('works in various modes and sees correct `mode()` value', function() -- cgit From 7ac5359143ef25c4c8c0c427d5533f8d5824ed17 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 29 Apr 2022 21:00:58 +0800 Subject: feat(mappings): do not simplify the rhs of a mapping --- test/functional/ui/input_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/functional') diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 0f4e97088c..07582ba602 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -313,6 +313,11 @@ it('unsimplified mapping works when there was a partial match vim-patch:8.2.4504 expect('xb') end) +it('rhs of a mapping is not simplified', function() + command('nnoremap foo ') + eq('', funcs.maparg('foo')) +end) + describe('input non-printable chars', function() after_each(function() os.remove('Xtest-overwrite') -- cgit