mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 19:07:58 +01:00
Don't collapse command-line selection on mode change.
This commit is contained in:
@@ -42,12 +42,13 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
getElement: CommandWidgets.getEditor,
|
getElement: CommandWidgets.getEditor,
|
||||||
getGroup: function (value) this.activeGroup.commandline,
|
getGroup: function (value) this.activeGroup.commandline,
|
||||||
onChange: function (elem) {
|
onChange: function (elem) {
|
||||||
|
if (!elem.collapsed && elem.inputField != dactyl.focus) {
|
||||||
elem.selectionStart = elem.value.length;
|
elem.selectionStart = elem.value.length;
|
||||||
elem.selectionEnd = elem.value.length;
|
elem.selectionEnd = elem.value.length;
|
||||||
if (!elem.collapsed)
|
|
||||||
elem.focus();
|
elem.focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onVisibility: function (elem, visible) visible && elem.focus()
|
onVisibility: function (elem, visible) visible && elem.inputField != dactyl.focus && elem.focus()
|
||||||
});
|
});
|
||||||
this.addElem({
|
this.addElem({
|
||||||
name: "prompt",
|
name: "prompt",
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
const Editor = Module("editor", {
|
const Editor = Module("editor", {
|
||||||
init: function () {
|
init: function () {
|
||||||
// store our last search with f, F, t or T
|
// store our last search with f, F, t or T
|
||||||
//
|
|
||||||
this._lastFindChar = null;
|
this._lastFindChar = null;
|
||||||
this._lastFindCharFunc = null;
|
this._lastFindCharFunc = null;
|
||||||
},
|
},
|
||||||
@@ -348,10 +347,7 @@ const Editor = Module("editor", {
|
|||||||
if (textBox)
|
if (textBox)
|
||||||
textBox.value = val;
|
textBox.value = val;
|
||||||
else {
|
else {
|
||||||
let wholeDocRange = editor.document.createRange();
|
editor.selection.addRange(RangeFind.nodeRange(editor.rootNode));
|
||||||
let rootNode = editor.rootElement.QueryInterface(Ci.nsIDOMNode);
|
|
||||||
wholeDocRange.selectNodeContents(rootNode);
|
|
||||||
editor.selection.addRange(wholeDocRange);
|
|
||||||
editor.selection.deleteFromDocument();
|
editor.selection.deleteFromDocument();
|
||||||
editor.insertText(val);
|
editor.insertText(val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,13 +226,12 @@ const Mappings = Module("mappings", {
|
|||||||
keys = keys.map(this._expandLeader);
|
keys = keys.map(this._expandLeader);
|
||||||
extra = extra || {};
|
extra = extra || {};
|
||||||
extra.user = true;
|
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
|
// 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))
|
for (let [, mode] in Iterator(map.modes))
|
||||||
this._removeMap(mode, name);
|
this._removeMap(mode, name);
|
||||||
}
|
|
||||||
|
|
||||||
this._addMap(map);
|
this._addMap(map);
|
||||||
},
|
},
|
||||||
@@ -269,22 +268,11 @@ const Mappings = Module("mappings", {
|
|||||||
* @param {string} prefix The map prefix string to match.
|
* @param {string} prefix The map prefix string to match.
|
||||||
* @returns {Map[]}
|
* @returns {Map[]}
|
||||||
*/
|
*/
|
||||||
getCandidates: function (mode, prefix) {
|
getCandidates: function (mode, prefix)
|
||||||
let mappings = this._user[mode].concat(this._main[mode]);
|
this._user[mode].concat(this._main[mode])
|
||||||
let matches = [];
|
.filter(function (map) map.names.some(
|
||||||
|
function (name) name.indexOf(prefix) == 0 && name.length > prefix.length
|
||||||
for (let [, map] in Iterator(mappings)) {
|
&& (prefix != "<" || !/^<.+>/.test(name)))),
|
||||||
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;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether there is a user-defined mapping *cmd* for the specified
|
* Returns whether there is a user-defined mapping *cmd* for the specified
|
||||||
@@ -350,7 +338,7 @@ const Mappings = Module("mappings", {
|
|||||||
</table>;
|
</table>;
|
||||||
|
|
||||||
// TODO: Move this to an ItemList to show this automatically
|
// 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");
|
dactyl.echomsg("No mapping found");
|
||||||
else
|
else
|
||||||
commandline.commandOutput(list);
|
commandline.commandOutput(list);
|
||||||
|
|||||||
@@ -246,10 +246,9 @@ const Modes = Module("modes", {
|
|||||||
if (push)
|
if (push)
|
||||||
this._modeStack.push(push);
|
this._modeStack.push(push);
|
||||||
|
|
||||||
if (stack && stack.pop) {
|
if (stack && stack.pop)
|
||||||
for (let [k, { obj, prop, value }] in Iterator(this.topOfStack.saved))
|
for (let { obj, prop, value } in values(this.topOfStack.saved))
|
||||||
obj[prop] = value;
|
obj[prop] = value;
|
||||||
}
|
|
||||||
|
|
||||||
if (this.topOfStack.params.enter && prev)
|
if (this.topOfStack.params.enter && prev)
|
||||||
this.topOfStack.params.enter(push ? { push: push } : stack || {},
|
this.topOfStack.params.enter(push ? { push: push } : stack || {},
|
||||||
|
|||||||
Reference in New Issue
Block a user