diff --git a/common/content/buffer.js b/common/content/buffer.js index df6e2329..020d9bdd 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1420,7 +1420,7 @@ var Buffer = Module("buffer", { let arg = args[0]; let opt = options.get("pageinfo"); - dactyl.assert(opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg); + dactyl.assert(!arg || opt.validator(opt.parse(arg)), "E475: Invalid argument: " + arg); buffer.showPageInfo(true, arg); }, { diff --git a/common/content/commandline.js b/common/content/commandline.js index 02d4073c..6e80147d 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -269,22 +269,29 @@ var CommandWidgets = Class("CommandWidgets", { }, get completionList() this._whenReady("completionList", "dactyl-completions"), - completionContainer: Class.memoize(function () this.completionList.parentNode), - get multilineOutput() this._whenReady("multilineOutput", "dactyl-multiline-output", - function (elem) { - elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true); - elem.contentDocument.documentElement.id = "dactyl-multiline-output-top"; - elem.contentDocument.body.id = "dactyl-multiline-output-content"; + completionContainer: Class.memoize(function () this.completionList.parentNode), + + contextMenu: Class.memoize(function () { ["copy", "copylink", "selectall"].forEach(function (tail) { // some host apps use "hostPrefixContext-copy" ids let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]"; document.getElementById("dactyl-context-" + tail).style.listStyleImage = util.computedStyle(util.evaluateXPath(xpath, document).snapshotItem(0)).listStyleImage; }); + return document.getElementById("dactyl-contextmenu"); + }), + + get multilineOutput() this._whenReady("multilineOutput", "dactyl-multiline-output", + function (elem) { + elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true); + elem.contentDocument.documentElement.id = "dactyl-multiline-output-top"; + elem.contentDocument.body.id = "dactyl-multiline-output-content"; return elem; }), + multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")), + mowContainer: Class.memoize(function () document.getElementById("dactyl-multiline-output-container")) }, { getEditor: function getEditor(elem) { @@ -331,16 +338,16 @@ var CommandMode = Class("CommandMode", { }, leave: function (stack) { - if (this.completions) - this.completions.cleanup(); - - if (this.history) - this.history.save(); - - commandline.hideCompletions(); - this.resetCompletions(); - if (!stack.push) { + if (this.completions) + this.completions.cleanup(); + + if (this.history) + this.history.save(); + + commandline.hideCompletions(); + this.resetCompletions(); + modes.delay(function () { if (!this.keepCommand || commandline.silent || commandline.quiet) commandline.hide(); @@ -1120,6 +1127,7 @@ var CommandLine = Module("commandline", { if (show) { this.itemList.reset(); + this.itemList.visible = true; this.selected = null; this.wildIndex = 0; } diff --git a/common/content/mow.js b/common/content/mow.js index 6a8ff4d7..c1c4b200 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -172,13 +172,14 @@ var MOW = Module("mow", { }, contextEvents: { popupshowing: function (event) { + let menu = commandline.widgets.contextMenu; let enabled = { link: window.document.popupNode instanceof HTMLAnchorElement, path: window.document.popupNode.hasAttribute("path"), selection: !window.document.commandDispatcher.focusedWindow.getSelection().isCollapsed }; - for (let node in array.iterValues(event.target.children)) { + for (let node in array.iterValues(menu.children)) { let group = node.getAttributeNS(NS, "group"); node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]); }