aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-09-08 09:23:19 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2018-09-13 11:02:24 +0200
commit5056d40b16a3a97fc927c81ca3aa8f8bd6e44e4b (patch)
tree08e32d5c221e8ae29693cf276150a8647af3dc52
parentd0c8dfc578dfda90a9f1311e9bb919f93df1a445 (diff)
downloadrneovim-5056d40b16a3a97fc927c81ca3aa8f8bd6e44e4b.tar.gz
rneovim-5056d40b16a3a97fc927c81ca3aa8f8bd6e44e4b.tar.bz2
rneovim-5056d40b16a3a97fc927c81ca3aa8f8bd6e44e4b.zip
getchar: allow <SID> in <Cmd> mapping
-rw-r--r--src/nvim/getchar.c10
-rw-r--r--test/functional/ex_cmds/cmd_map_spec.lua12
2 files changed, 20 insertions, 2 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 8f1e5bb6c1..061b220f0e 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -4315,8 +4315,14 @@ char_u * getcmdkeycmd(int promptc, void *cookie, int indent)
EMSG(e_cmdmap_repeated);
aborted = true;
} else if (IS_SPECIAL(c1)) {
- EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
- aborted = true;
+ if (c1 == K_SNR) {
+ ga_append(&line_ga, (char)K_SPECIAL);
+ ga_append(&line_ga, (char)KS_EXTRA);
+ ga_append(&line_ga, (char)KE_SNR);
+ } else {
+ EMSG2(e_cmdmap_key, get_special_key_name(c1, cmod));
+ aborted = true;
+ }
} else {
ga_append(&line_ga, (char)c1);
}
diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua
index acb76e382d..67b3ab49d6 100644
--- a/test/functional/ex_cmds/cmd_map_spec.lua
+++ b/test/functional/ex_cmds/cmd_map_spec.lua
@@ -8,6 +8,7 @@ local eval = helpers.eval
local funcs = helpers.funcs
local insert = helpers.insert
local exc_exec = helpers.exc_exec
+local source = helpers.source
local Screen = require('test.functional.ui.screen')
describe('mappings with <Cmd>', function()
@@ -794,5 +795,16 @@ describe('mappings with <Cmd>', function()
]])
end)
+ it("works with <SID> mappings", function()
+ source([[
+ map <f2> <Cmd>call <SID>do_it()<Cr>
+ function! s:do_it()
+ let g:x = 10
+ endfunction
+ ]])
+ feed('<f2>')
+ eq('', eval('v:errmsg'))
+ eq(10, eval('g:x'))
+ end)
end)