[evolution/wip/mcrha/webkit-jsc-api] e-undo-redo.js: Modify selection before delete only when it's collapsed
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/mcrha/webkit-jsc-api] e-undo-redo.js: Modify selection before delete only when it's collapsed
- Date: Tue, 26 Nov 2019 08:42:17 +0000 (UTC)
commit 7e5c769746dc1d3940a75a15fd8ca355232c6cf7
Author: Milan Crha <mcrha redhat com>
Date: Tue Nov 26 09:43:08 2019 +0100
e-undo-redo.js: Modify selection before delete only when it's collapsed
data/webkit/e-undo-redo.js | 96 +++++++++++++++++++++++-----------------------
1 file changed, 49 insertions(+), 47 deletions(-)
---
diff --git a/data/webkit/e-undo-redo.js b/data/webkit/e-undo-redo.js
index 3a18649762..bad85b764b 100644
--- a/data/webkit/e-undo-redo.js
+++ b/data/webkit/e-undo-redo.js
@@ -384,53 +384,55 @@ EvoUndoRedo.before_input_cb = function(inputEvent)
if (EvoUndoRedo.isWordDelimEvent(inputEvent))
opType += "::WordDelim";
- if (opType == "deleteWordBackward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "backward", "word");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteWordForward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "forward", "word");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteSoftLineBackward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "backward", "line");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteSoftLineForward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "forward", "line");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteEntireSoftLine") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "backward", "line");
- startNode = document.getSelection().baseNode;
- document.getSelection().modify("move", "forward", "line");
- endNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteHardLineBackward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "backward", "paragraph");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteHardLineForward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "forward", "paragraph");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteContentBackward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "backward", "paragraph");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
- } else if (opType == "deleteContentForward") {
- var sel = EvoSelection.Store(document);
- document.getSelection().modify("move", "forward", "paragraph");
- startNode = document.getSelection().baseNode;
- EvoSelection.Restore(document, sel);
+ if (document.getSelection().isCollapsed) {
+ if (opType == "deleteWordBackward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "backward", "word");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteWordForward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "forward", "word");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteSoftLineBackward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "backward", "line");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteSoftLineForward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "forward", "line");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteEntireSoftLine") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "backward", "line");
+ startNode = document.getSelection().baseNode;
+ document.getSelection().modify("move", "forward", "line");
+ endNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteHardLineBackward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "backward", "paragraph");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteHardLineForward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "forward", "paragraph");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteContentBackward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "backward", "paragraph");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ } else if (opType == "deleteContentForward") {
+ var sel = EvoSelection.Store(document);
+ document.getSelection().modify("move", "forward", "paragraph");
+ startNode = document.getSelection().baseNode;
+ EvoSelection.Restore(document, sel);
+ }
}
record = EvoUndoRedo.StartRecord(EvoUndoRedo.RECORD_KIND_EVENT, opType, startNode, endNode,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]