mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 09:48:00 +01:00
Fix a bug in replacing user commands. Closes issue #88.
--HG-- extra : rebase_source : 3d5045b548a81ec70e43ab1e3d006a975f95b974
This commit is contained in:
@@ -8,12 +8,13 @@
|
||||
|
||||
/** @scope modules */
|
||||
|
||||
// Do NOT create instances of this class yourself, use the helper method
|
||||
// commands.add() instead
|
||||
|
||||
/**
|
||||
* A structure representing the options available for a command.
|
||||
*
|
||||
* Do NOT create instances of this class yourself, use the helper method
|
||||
* {@see Commands#add} instead
|
||||
*
|
||||
* @property {[string]} names An array of option names. The first name
|
||||
* is the canonical option name.
|
||||
* @property {number} type The option's value type. This is one of:
|
||||
@@ -334,7 +335,7 @@ const Commands = Module("commands", {
|
||||
_addCommand: function (args, replace) {
|
||||
let names = array.flatten(Command.parseSpecs(args[0]));
|
||||
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this),
|
||||
"E182: Can't replace non-user command: " + args[0]);
|
||||
"E182: Can't replace non-user command: " + args[0][0]);
|
||||
if (!replace || !(args[3] && args[3].user))
|
||||
dactyl.assert(!names.some(function (name) name in this._exMap, this),
|
||||
"Not replacing command " + args[0]);
|
||||
@@ -937,9 +938,9 @@ const Commands = Module("commands", {
|
||||
removeUserCommand: function (name) {
|
||||
let cmd = this.get(name);
|
||||
dactyl.assert(cmd.user, "E184: No such user-defined command: " + name);
|
||||
for (let name in array.iterValues(cmd.names))
|
||||
this._exCommands = this._exCommands.filter(function (c) c !== cmd);
|
||||
for (let name in values(cmd.names))
|
||||
delete this._exMap[name];
|
||||
this._exCommands = this._exCommands.filter(function (c) c != cmd);
|
||||
},
|
||||
|
||||
// FIXME: still belong here? Also used for autocommand parameters.
|
||||
|
||||
Reference in New Issue
Block a user