diff --git a/common/content/commandline.js b/common/content/commandline.js index d3f21513..a66f3c77 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -42,12 +42,13 @@ const CommandWidgets = Class("CommandWidgets", { getElement: CommandWidgets.getEditor, getGroup: function (value) this.activeGroup.commandline, onChange: function (elem) { - elem.selectionStart = elem.value.length; - elem.selectionEnd = elem.value.length; - if (!elem.collapsed) + if (!elem.collapsed && elem.inputField != dactyl.focus) { + elem.selectionStart = elem.value.length; + elem.selectionEnd = elem.value.length; elem.focus(); + } }, - onVisibility: function (elem, visible) visible && elem.focus() + onVisibility: function (elem, visible) visible && elem.inputField != dactyl.focus && elem.focus() }); this.addElem({ name: "prompt", diff --git a/common/content/editor.js b/common/content/editor.js index 5ad8e771..fd08de87 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -13,7 +13,6 @@ const Editor = Module("editor", { init: function () { // store our last search with f, F, t or T - // this._lastFindChar = null; this._lastFindCharFunc = null; }, @@ -348,10 +347,7 @@ const Editor = Module("editor", { if (textBox) textBox.value = val; else { - let wholeDocRange = editor.document.createRange(); - let rootNode = editor.rootElement.QueryInterface(Ci.nsIDOMNode); - wholeDocRange.selectNodeContents(rootNode); - editor.selection.addRange(wholeDocRange); + editor.selection.addRange(RangeFind.nodeRange(editor.rootNode)); editor.selection.deleteFromDocument(); editor.insertText(val); } diff --git a/common/content/mappings.js b/common/content/mappings.js index dc1e54d9..6768a97a 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -226,13 +226,12 @@ const Mappings = Module("mappings", { keys = keys.map(this._expandLeader); extra = extra || {}; extra.user = true; - let map = Map(modes, keys, description || "User-defined mapping", action, extra); + let map = Map(modes, keys, description, action, extra); // remove all old mappings to this key sequence - for (let [, name] in Iterator(map.names)) { + for (let [, name] in Iterator(map.names)) for (let [, mode] in Iterator(map.modes)) this._removeMap(mode, name); - } this._addMap(map); }, @@ -269,22 +268,11 @@ const Mappings = Module("mappings", { * @param {string} prefix The map prefix string to match. * @returns {Map[]} */ - getCandidates: function (mode, prefix) { - let mappings = this._user[mode].concat(this._main[mode]); - let matches = []; - - for (let [, map] in Iterator(mappings)) { - for (let [, name] in Iterator(map.names)) { - if (name.indexOf(prefix) == 0 && name.length > prefix.length) { - // for < only return a candidate if it doesn't look like a mapping - if (prefix != "<" || !/^<.+>/.test(name)) - matches.push(map); - } - } - } - - return matches; - }, + getCandidates: function (mode, prefix) + this._user[mode].concat(this._main[mode]) + .filter(function (map) map.names.some( + function (name) name.indexOf(prefix) == 0 && name.length > prefix.length + && (prefix != "<" || !/^<.+>/.test(name)))), /** * Returns whether there is a user-defined mapping *cmd* for the specified @@ -350,7 +338,7 @@ const Mappings = Module("mappings", { ; // TODO: Move this to an ItemList to show this automatically - if (list.*.length() == list.text().length()) + if (list.*.length() === list.text().length()) dactyl.echomsg("No mapping found"); else commandline.commandOutput(list); diff --git a/common/content/modes.js b/common/content/modes.js index 4533d0ca..36d06ef3 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -246,10 +246,9 @@ const Modes = Module("modes", { if (push) this._modeStack.push(push); - if (stack && stack.pop) { - for (let [k, { obj, prop, value }] in Iterator(this.topOfStack.saved)) + if (stack && stack.pop) + for (let { obj, prop, value } in values(this.topOfStack.saved)) obj[prop] = value; - } if (this.topOfStack.params.enter && prev) this.topOfStack.params.enter(push ? { push: push } : stack || {},