From ddf4d0224466ba25f217dd16801f2f269814b161 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 6 Oct 2011 10:58:31 -0400 Subject: [PATCH] Fix some selection mode change stupidiocy with noinsertmode set. --- common/content/editor.js | 12 +++++++++--- common/content/events.js | 31 +++++++++++-------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/common/content/editor.js b/common/content/editor.js index f8df43b4..3d47936b 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -346,7 +346,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { else if (/^[+-]?0\d/.test(range)) 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"); }, @@ -511,7 +512,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { let abbrev = abbreviations.match(mode, String(range)); if (abbrev) { 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"] = { + preExecute: function preExecute(args) { + editor.inEditMap = true; + }, postExecute: function preExecute(args) { + editor.inEditMap = true; if (modes.main == modes.OPERATOR) modes.pop(); - }, + } }; // add mappings for commands like h,j,k,l,etc. in CARET, VISUAL and TEXT_EDIT mode diff --git a/common/content/events.js b/common/content/events.js index 6456e7e5..66d93d66 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -867,21 +867,16 @@ var Events = Module("events", { let haveInput = modes.stack.some(function (m) m.main.input); - if (elem instanceof HTMLTextAreaElement - || 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 (DOM(elem || win).isEditable) { if (!haveInput) - if (options["insertmode"]) - modes.push(modes.INSERT); - else if (!isinstance(modes.main, [modes.TEXT_EDIT, modes.VISUAL])) { - modes.push(modes.TEXT_EDIT); - if (elem.selectionEnd - elem.selectionStart > 0) - modes.push(modes.VISUAL); - } + if (!isinstance(modes.main, [modes.INPUT, modes.TEXT_EDIT, modes.VISUAL])) + if (options["insertmode"]) + modes.push(modes.INSERT); + else { + modes.push(modes.TEXT_EDIT); + if (elem.selectionEnd - elem.selectionStart > 0) + modes.push(modes.VISUAL); + } if (hasHTMLDocument(win)) buffer.lastInputField = elem; @@ -926,12 +921,8 @@ var Events = Module("events", { let controller = document.commandDispatcher.getControllerForCommand("cmd_copy"); let couldCopy = controller && controller.isCommandEnabled("cmd_copy"); - if (modes.main == modes.VISUAL) { - if (!couldCopy) - modes.pop(); // Really not ideal. - } - else if (couldCopy) { - if (modes.main == modes.TEXT_EDIT && !options["insertmode"]) + if (couldCopy) { + if (modes.main == modes.TEXT_EDIT) modes.push(modes.VISUAL); else if (modes.main == modes.CARET) modes.push(modes.VISUAL);