aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-12-23 15:30:44 +0800
committerGitHub <noreply@github.com>2023-12-23 15:30:44 +0800
commit3c667d3e0fe41a900cee9477e190ae02d7ec0c23 (patch)
tree51e5a3723071a2e6a788040b60c3d7946381e35e
parent242261d4e77806cdb4559c2be58613113a393a4e (diff)
downloadrneovim-3c667d3e0fe41a900cee9477e190ae02d7ec0c23.tar.gz
rneovim-3c667d3e0fe41a900cee9477e190ae02d7ec0c23.tar.bz2
rneovim-3c667d3e0fe41a900cee9477e190ae02d7ec0c23.zip
fix(mappings): fix mapset() not replacing map with backslash (#26719)
-rw-r--r--src/nvim/mapping.c2
-rw-r--r--test/functional/vimscript/map_functions_spec.lua10
2 files changed, 11 insertions, 1 deletions
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index cb50050344..c7fa585a27 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -2350,7 +2350,7 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// Delete any existing mapping for this lhs and mode.
MapArguments unmap_args = MAP_ARGUMENTS_INIT;
- set_maparg_lhs_rhs(lhs, strlen(lhs), "", 0, LUA_NOREF, 0, &unmap_args);
+ set_maparg_lhs_rhs(lhs, strlen(lhs), "", 0, LUA_NOREF, CPO_TO_CPO_FLAGS, &unmap_args);
unmap_args.buffer = buffer;
buf_do_map(MAPTYPE_UNMAP, &unmap_args, mode, is_abbr, curbuf);
xfree(unmap_args.rhs);
diff --git a/test/functional/vimscript/map_functions_spec.lua b/test/functional/vimscript/map_functions_spec.lua
index acba5e9708..e3cc653e12 100644
--- a/test/functional/vimscript/map_functions_spec.lua
+++ b/test/functional/vimscript/map_functions_spec.lua
@@ -180,6 +180,16 @@ end)
describe('mapset()', function()
before_each(clear)
+ it('can restore mapping with backslash in lhs', function()
+ meths.set_keymap('n', '\\ab', 'a', {})
+ eq('\nn \\ab a', exec_capture("nmap \\ab"))
+ local mapargs = funcs.maparg('\\ab', 'n', false, true)
+ meths.set_keymap('n', '\\ab', 'b', {})
+ eq('\nn \\ab b', exec_capture("nmap \\ab"))
+ funcs.mapset('n', false, mapargs)
+ eq('\nn \\ab a', exec_capture("nmap \\ab"))
+ end)
+
it('can restore mapping description from the dict returned by maparg()', function()
meths.set_keymap('n', 'lhs', 'rhs', {desc = 'map description'})
eq('\nn lhs rhs\n map description', exec_capture("nmap lhs"))