[evolution] I#1207 - Composer: Magic-links can reposition caret to incorrect place
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1207 - Composer: Magic-links can reposition caret to incorrect place
- Date: Thu, 5 Nov 2020 15:56:46 +0000 (UTC)
commit 9c84a78a3d18a78c140dc442b7257b68a6ccab4f
Author: Milan Crha <mcrha redhat com>
Date: Thu Nov 5 16:55:30 2020 +0100
I#1207 - Composer: Magic-links can reposition caret to incorrect place
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1207
data/webkit/e-editor.js | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index e8ace1f68c..dbc0127141 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -3087,16 +3087,18 @@ EvoEditor.linkifyText = function(anchorNode, withUndo)
parent = anchorNode.parentElement;
for (ii = 0; ii < parts.length; ii++) {
- var part = parts[ii], node, isLast = ii + 1 >= parts.length;
+ var part = parts[ii], node, isLast = ii + 1 >= parts.length, textLen =
part.text.length;
if (part.href) {
node = document.createElement("A");
node.href = part.href;
node.innerText = part.text;
} else if (isLast) {
- node = null;
// it can be a space, which cannot be added after the element, thus
workaround it this way
- newAnchorNode = anchorNode.splitText(matchEnd);
+ node = anchorNode.splitText(matchEnd);
+ if (!newAnchorNode && offset <= textLen)
+ newAnchorNode = node;
+ node = null;
} else {
node = document.createTextNode(part.text);
}
@@ -3104,18 +3106,19 @@ EvoEditor.linkifyText = function(anchorNode, withUndo)
if (node)
parent.insertBefore(node, insBefore);
- if (!isLast) {
- matchEnd += part.text.length;
- } else if (node) {
+ if (node && !newAnchorNode && offset <= textLen)
newAnchorNode = node;
- }
+ else if (!newAnchorNode && offset > textLen)
+ offset -= textLen;
+
+ matchEnd += textLen;
}
if (anchorNode)
anchorNode.remove();
- if (updateSelection && newAnchorNode && offset - matchEnd >= 0)
- selection.setPosition(newAnchorNode, offset - matchEnd);
+ if (updateSelection && newAnchorNode)
+ selection.setPosition(newAnchorNode, offset);
} finally {
if (withUndo) {
EvoUndoRedo.StopRecord(EvoUndoRedo.RECORD_KIND_CUSTOM, "magicLink");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]