r99452 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99451‎ | r99452 | r99453 >
Date:00:24, 11 October 2011
Author:neilk
Status:deferred
Tags:
Comment:
make prepareRemoval test pass (naively -- will add better test next)
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js (modified) (history)
  • /trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/tests/hype/es.DocumentModel.test.js
@@ -351,7 +351,7 @@
352352 ['c', { 'type': 'italic', 'hash': '#italic' }]
353353 ]
354354 },
355 - { 'type': 'retain', 'length': 25 }
 355+ { 'type': 'retain', 'length': 24 }
356356 ],
357357 'prepareRemoval includes the content being removed'
358358 );
Index: trunk/parsers/wikidom/lib/hype/models/es.DocumentModel.js
@@ -583,6 +583,26 @@
584584 */
585585 es.DocumentModel.prototype.prepareRemoval = function( range ) {
586586 var tx = new es.Transaction();
 587+ range.normalize();
 588+
 589+ if ( range.start > 0 ) {
 590+ tx.pushRetain( range.start );
 591+ }
 592+
 593+ var i = range.start;
 594+ removeData = [];
 595+ while ( i < range.end ) {
 596+ var data = this.data[i];
 597+ if ( data.type !== undefined ) {
 598+ console.log( "later" );
 599+ // TODO structural
 600+ } else {
 601+ removeData.push( this.data[i] );
 602+ }
 603+ i++;
 604+ }
 605+ tx.pushRemove( removeData );
 606+
587607 /*
588608 * // Structural changes
589609 * if ( The range spans structural elements ) {
@@ -594,7 +614,13 @@
595615 * } else {
596616 * Removing only content is OK, do nothing
597617 * }
598 - */
 618+ /
 619+ i++;
 620+ }
 621+ */
 622+ if ( range.end < this.data.length ) {
 623+ tx.pushRetain( this.data.length - range.end );
 624+ }
599625 return tx;
600626 };
601627

Follow-up revisions

RevisionCommit summaryAuthorDate
r99489Merge duplicate code from r99452 and r99487 (communication snafu between me a...catrope16:15, 11 October 2011

Status & tagging log