mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
Merge pull request #26720 from neovim/backport-26719-to-release-0.9
[Backport release-0.9] fix(mappings): fix mapset() not replacing map with backslash
This commit is contained in:
commit
450c6d7584
@ -2253,7 +2253,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);
|
||||
|
@ -174,6 +174,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"))
|
||||
|
Loading…
Reference in New Issue
Block a user