r102695 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102694‎ | r102695 | r102696 >
Date:21:43, 10 November 2011
Author:inez
Status:deferred
Tags:
Comment:
Make getWordBoundaries returns null if given offset refers to element data. Also if given offset is beginning of the word then search for not beginning of the word offsets around (and other way round).
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js
@@ -822,10 +822,13 @@
823823 * @returns {es.Range|null} Range of content making up a whole word or null if offset is not content
824824 */
825825 es.DocumentModel.prototype.getWordBoundaries = function( offset ) {
826 - if ( es.DocumentModel.isStructuralOffset( this.data, offset ) ) {
 826+ if ( es.DocumentModel.isStructuralOffset( this.data, offset ) ||
 827+ es.DocumentModel.isElementData( this.data, offset ) ) {
827828 return null;
828829 }
829 - var start = offset,
 830+
 831+ var regex = this.data[offset].match( /\B/ ) ? /\b/ : /\B/,
 832+ start = offset,
830833 end = offset,
831834 item;
832835 while ( start > 0 ) {
@@ -835,7 +838,7 @@
836839 break;
837840 }
838841 item = typeof this.data[start] === 'string' ? this.data[start] : this.data[start][0];
839 - if ( item.match( /\B/ ) ) {
 842+ if ( item.match( regex ) ) {
840843 start++;
841844 break;
842845 }
@@ -845,7 +848,7 @@
846849 break;
847850 }
848851 item = typeof this.data[end] === 'string' ? this.data[end] : this.data[end][0];
849 - if ( item.match( /\B/ ) ) {
 852+ if ( item.match( regex ) ) {
850853 break;
851854 }
852855 end++;

Status & tagging log