jenkins-bot has submitted this change and it was merged.

Change subject: Fix ContentBranchNode echo suppression at the ends of text nodes
......................................................................


Fix ContentBranchNode echo suppression at the ends of text nodes

Rename selectionInsideOneBranchNode() to selectionInsideOneLeafNode(),
and use selectNodes() to check if the selection only covers one node.

This is needed because we don't just care about the selection being
within a CBN, we also want to steer clear of selections from a
text node across an inline node into another text node, those are
not "simple".

Change-Id: I85fe939d3709e65e7094cbc55f29bdeb673df15a
---
M modules/ve/ce/ve.ce.Surface.js
1 file changed, 6 insertions(+), 8 deletions(-)

Approvals:
  Divec: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js
index 35c1bee..f0fa455 100644
--- a/modules/ve/ce/ve.ce.Surface.js
+++ b/modules/ve/ce/ve.ce.Surface.js
@@ -1616,7 +1616,7 @@
                annotations = documentModel.data.getAnnotationsFromRange(
                        new ve.Range( selection.start, selection.start + 1 )
                );
-               if ( !this.selectionInsideOneBranchNode( selection ) ) {
+               if ( !this.selectionInsideOneLeafNode( selection ) ) {
                        this.model.change(
                                ve.dm.Transaction.newFromRemoval(
                                        this.documentView.model,
@@ -1667,15 +1667,13 @@
 };
 
 /**
- * Test whether selection lies within a single branch node
+ * Test whether selection lies within a single leaf node
  * @param {ve.Range} selection The selection to test
- * @returns {boolean} Whether the selection lies within a single branch node
+ * @returns {boolean} Whether the selection lies within a single node
  */
-ve.ce.Surface.prototype.selectionInsideOneBranchNode = function ( selection ) {
-       var startNode, endNode;
-       startNode = this.documentView.getDocumentNode().getNodeFromOffset( 
selection.start );
-       endNode = this.documentView.getDocumentNode().getNodeFromOffset( 
selection.end );
-       return startNode === endNode;
+ve.ce.Surface.prototype.selectionInsideOneLeafNode = function ( selection ) {
+       var selected = this.documentView.selectNodes( selection, 'leaves' );
+       return selected.length === 1;
 };
 
 /**

-- 
To view, visit https://gerrit.wikimedia.org/r/118792
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I85fe939d3709e65e7094cbc55f29bdeb673df15a
Gerrit-PatchSet: 6
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to