mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-17 00:43:33 +01:00
Fix some selection mode change stupidiocy with noinsertmode set.
This commit is contained in:
@@ -346,7 +346,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
|||||||
else if (/^[+-]?0\d/.test(range))
|
else if (/^[+-]?0\d/.test(range))
|
||||||
number = number.toString(8).replace(/^[+-]?/, "$&0");
|
number = number.toString(8).replace(/^[+-]?/, "$&0");
|
||||||
|
|
||||||
this.mungeRange(range, function () String(number), true);
|
this.selectedRange = range;
|
||||||
|
this.editor.insertText(String(number));
|
||||||
this.selection.modify("move", "backward", "character");
|
this.selection.modify("move", "backward", "character");
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -511,7 +512,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
|||||||
let abbrev = abbreviations.match(mode, String(range));
|
let abbrev = abbreviations.match(mode, String(range));
|
||||||
if (abbrev) {
|
if (abbrev) {
|
||||||
range.setStart(range.startContainer, range.endOffset - abbrev.lhs.length);
|
range.setStart(range.startContainer, range.endOffset - abbrev.lhs.length);
|
||||||
this.mungeRange(range, function () abbrev.expand(this.element), true);
|
this.selectedRange = range;
|
||||||
|
this.editor.insertText(abbrev.expand(this.element));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -786,10 +788,14 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
Map.types["operator"] = {
|
Map.types["operator"] = {
|
||||||
|
preExecute: function preExecute(args) {
|
||||||
|
editor.inEditMap = true;
|
||||||
|
},
|
||||||
postExecute: function preExecute(args) {
|
postExecute: function preExecute(args) {
|
||||||
|
editor.inEditMap = true;
|
||||||
if (modes.main == modes.OPERATOR)
|
if (modes.main == modes.OPERATOR)
|
||||||
modes.pop();
|
modes.pop();
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXT_EDIT mode
|
// add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXT_EDIT mode
|
||||||
|
|||||||
@@ -867,21 +867,16 @@ var Events = Module("events", {
|
|||||||
|
|
||||||
let haveInput = modes.stack.some(function (m) m.main.input);
|
let haveInput = modes.stack.some(function (m) m.main.input);
|
||||||
|
|
||||||
if (elem instanceof HTMLTextAreaElement
|
if (DOM(elem || win).isEditable) {
|
||||||
|| elem instanceof Element && DOM(elem).style.MozUserModify === "read-write"
|
|
||||||
|| elem == null && win && Editor.getEditor(win)) {
|
|
||||||
|
|
||||||
if (modes.main == modes.VISUAL && elem.selectionEnd == elem.selectionStart)
|
|
||||||
modes.pop();
|
|
||||||
|
|
||||||
if (!haveInput)
|
if (!haveInput)
|
||||||
if (options["insertmode"])
|
if (!isinstance(modes.main, [modes.INPUT, modes.TEXT_EDIT, modes.VISUAL]))
|
||||||
modes.push(modes.INSERT);
|
if (options["insertmode"])
|
||||||
else if (!isinstance(modes.main, [modes.TEXT_EDIT, modes.VISUAL])) {
|
modes.push(modes.INSERT);
|
||||||
modes.push(modes.TEXT_EDIT);
|
else {
|
||||||
if (elem.selectionEnd - elem.selectionStart > 0)
|
modes.push(modes.TEXT_EDIT);
|
||||||
modes.push(modes.VISUAL);
|
if (elem.selectionEnd - elem.selectionStart > 0)
|
||||||
}
|
modes.push(modes.VISUAL);
|
||||||
|
}
|
||||||
|
|
||||||
if (hasHTMLDocument(win))
|
if (hasHTMLDocument(win))
|
||||||
buffer.lastInputField = elem;
|
buffer.lastInputField = elem;
|
||||||
@@ -926,12 +921,8 @@ var Events = Module("events", {
|
|||||||
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
|
||||||
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
|
let couldCopy = controller && controller.isCommandEnabled("cmd_copy");
|
||||||
|
|
||||||
if (modes.main == modes.VISUAL) {
|
if (couldCopy) {
|
||||||
if (!couldCopy)
|
if (modes.main == modes.TEXT_EDIT)
|
||||||
modes.pop(); // Really not ideal.
|
|
||||||
}
|
|
||||||
else if (couldCopy) {
|
|
||||||
if (modes.main == modes.TEXT_EDIT && !options["insertmode"])
|
|
||||||
modes.push(modes.VISUAL);
|
modes.push(modes.VISUAL);
|
||||||
else if (modes.main == modes.CARET)
|
else if (modes.main == modes.CARET)
|
||||||
modes.push(modes.VISUAL);
|
modes.push(modes.VISUAL);
|
||||||
|
|||||||
Reference in New Issue
Block a user