1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 19:27:58 +01:00

Don't collapse command-line selection on mode change.

This commit is contained in:
Kris Maglione
2010-10-23 18:12:39 -04:00
parent 6649a81f7d
commit 6f95b33694
4 changed files with 16 additions and 32 deletions

View File

@@ -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",

View File

@@ -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);
}

View File

@@ -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 <c-x> 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", {
</table>;
// 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);

View File

@@ -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 || {},