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

Change subject: Inside ve.ce.Document.getRelativeOffset fallback to 'character' 
mode if 'word' mode returns the same offset as was passed originally
......................................................................


Inside ve.ce.Document.getRelativeOffset fallback to 'character' mode if 'word' 
mode returns the same offset as was passed originally

Change-Id: Ia3de5d5c1f37f17161fb1c8c9a284c868bb4a5fb
---
M modules/ve/ce/ve.ce.Document.js
1 file changed, 9 insertions(+), 5 deletions(-)

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



diff --git a/modules/ve/ce/ve.ce.Document.js b/modules/ve/ce/ve.ce.Document.js
index 120571a..733b825 100644
--- a/modules/ve/ce/ve.ce.Document.js
+++ b/modules/ve/ce/ve.ce.Document.js
@@ -74,9 +74,6 @@
  * This method is in CE instead of DM because it uses information about slugs 
about which model
  * does not know at all.
  *
- * FIXME: In certain cases returned offset is the same as passed offset which 
prevents cursor from
- * moving.
- *
  * @method
  * @param {number} offset Offset to start from
  * @param {number} [direction] Direction to prefer matching offset in, -1 for 
left and 1 for right
@@ -84,9 +81,16 @@
  * @returns {number} Relative offset
  */
 ve.ce.Document.prototype.getRelativeOffset = function ( offset, direction, 
unit ) {
-       var bias, relativeContentOffset, relativeStructuralOffset;
+       var bias, relativeContentOffset, relativeStructuralOffset, newOffset;
        if ( unit === 'word' ) { // word
-               return this.getSiblingWordBoundary( offset, direction );
+               // Method getSiblingWordBoundary does not "move/jump" over 
element data. If passed offset is
+               // an element data offset then the same offset is returned - 
and in such case this method
+               // fallback to the other path (character) which does 
"move/jump" over element data.
+               newOffset = this.getSiblingWordBoundary( offset, direction );
+               if ( offset === newOffset ) {
+                       newOffset = this.getRelativeOffset( offset, direction, 
'character' );
+               }
+               return newOffset;
        } else { // character
                bias = direction > 0 ? 1 : -1;
                relativeContentOffset = 
this.model.data.getRelativeContentOffset( offset, direction );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia3de5d5c1f37f17161fb1c8c9a284c868bb4a5fb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Inez <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to