From c683abc2810889807836975f75c2eb1917e0eab5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 15 Oct 2010 14:10:06 -0400 Subject: [PATCH] Fix a bug in replacing user commands. Closes issue #88. --HG-- extra : rebase_source : 3d5045b548a81ec70e43ab1e3d006a975f95b974 --- common/content/commandline.js | 3 ++- common/content/commands.js | 11 ++++++----- common/content/dactyl.js | 1 + common/modules/sanitizer.jsm | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index 1bfbcfb9..cff4a08a 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -663,7 +663,8 @@ const CommandLine = Module("commandline", { this._echoMultiline({this._lastEcho}, this.widgets.message[0], true); - if (action === this._echoLine && !(flags & this.FORCE_MULTILINE) && !this.widgets.mowContainer.collapsed) { + if (action === this._echoLine && !(flags & this.FORCE_MULTILINE) + && !(dactyl.fullyInitialized && this.widgets.mowContainer.collapsed)) { highlightGroup += " Message"; action = this._echoMultiline; } diff --git a/common/content/commands.js b/common/content/commands.js index b2f6f18a..5ba7cd53 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -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. diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 02b2053a..86a1b1c2 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -2045,6 +2045,7 @@ const Dactyl = Module("dactyl", { dactyl.execute(cmd); }); + dactyl.fullyInitialized = true; dactyl.triggerObserver("enter", null); autocommands.trigger("Enter", {}); }, 0); diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index 0c9f797c..aca4e026 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -443,7 +443,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR services.get("permissions").remove(uri, "cookie"); services.get("permissions").add(uri, "cookie", Sanitizer.PERMS[perm]); } - commands.addUserCommand(["cookies", "ck"], + commands.add(["cookies", "ck"], "Change cookie permissions for sites.", function (args) { let host = args.shift(); @@ -497,7 +497,7 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR break; } }, - }, true); + }); }, completion: function (dactyl, modules, window) { modules.completion.visibleHosts = function completeHosts(context) {