mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-31 08:45:45 +01:00
Fix #334 (mkv! writes (v|n)noremap to vimperatorrc).
This commit is contained in:
@@ -213,41 +213,46 @@ function Mappings() //{{{
|
|||||||
// 0 args -> list all maps
|
// 0 args -> list all maps
|
||||||
// 1 arg -> list the maps starting with args
|
// 1 arg -> list the maps starting with args
|
||||||
// 2 args -> map arg1 to arg*
|
// 2 args -> map arg1 to arg*
|
||||||
function map(args, mode, noremap)
|
function map(args, modes, noremap)
|
||||||
{
|
{
|
||||||
if (!args.length)
|
if (!args.length)
|
||||||
{
|
{
|
||||||
mappings.list(mode);
|
mappings.list(modes);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let [lhs, rhs] = args;
|
let [lhs, rhs] = args;
|
||||||
|
|
||||||
if (!rhs) // list the mapping
|
if (!rhs) // list the mapping
|
||||||
mappings.list(mode, expandLeader(lhs));
|
mappings.list(modes, expandLeader(lhs));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// this matches Vim's behaviour
|
// this matches Vim's behaviour
|
||||||
if (/^<Nop>$/i.test(rhs))
|
if (/^<Nop>$/i.test(rhs))
|
||||||
noremap = true;
|
noremap = true;
|
||||||
|
|
||||||
for (let [,m] in Iterator(mode))
|
mappings.addUserMap(modes, [lhs],
|
||||||
{
|
"User defined mapping",
|
||||||
mappings.addUserMap([m], [lhs],
|
function (count) { events.feedkeys((count > -1 ? count : "") + this.rhs, this.noremap, this.silent); },
|
||||||
"User defined mapping",
|
{
|
||||||
function (count) { events.feedkeys((count > -1 ? count : "") + this.rhs, this.noremap, this.silent); },
|
count: true,
|
||||||
{
|
rhs: events.canonicalKeys(rhs),
|
||||||
count: true,
|
noremap: !!noremap,
|
||||||
rhs: events.canonicalKeys(rhs),
|
silent: "<silent>" in args
|
||||||
noremap: !!noremap,
|
});
|
||||||
silent: "<silent>" in args
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
modeDescription = modeDescription ? " in " + modeDescription + " mode" : "";
|
||||||
|
|
||||||
|
// :map, :noremap => NORMAL + VISUAL modes
|
||||||
|
function isMultiMode(map, cmd)
|
||||||
|
{
|
||||||
|
return map.modes.indexOf(modules.modes.NORMAL) >= 0
|
||||||
|
&& map.modes.indexOf(modules.modes.VISUAL) >= 0
|
||||||
|
&& /^[nv](nore)?map$/.test(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
completer: function (context, args) completion.userMapping(context, args, modes),
|
completer: function (context, args) completion.userMapping(context, args, modes),
|
||||||
options: [
|
options: [
|
||||||
@@ -265,7 +270,7 @@ function Mappings() //{{{
|
|||||||
literalArg: map.rhs
|
literalArg: map.rhs
|
||||||
}
|
}
|
||||||
for (map in mappingsIterator(modes, user))
|
for (map in mappingsIterator(modes, user))
|
||||||
if (map.rhs && map.noremap == noremap)
|
if (map.rhs && map.noremap == noremap && !isMultiMode(map, this.name))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user