Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Oct 24, 2018
1 parent dd85b76 commit 0701ab4
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/model/differ.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,20 +413,20 @@ export default class Differ {
}
}

console.log( diffSet.reduce( ( prev, curr ) => prev + ' ' + curr.changeCount, ' ' ) );

// Then, sort the changes by the position (change at position before other changes is first).
diffSet.sort( ( a, b ) => {
// If the change is in different root, we don't care much, but we'd like to have all changes in given
// root "together" in the array. So let's just sort them by the root name. It does not matter which root
// will be processed first.
if ( a.position.root != b.position.root ) {
console.log( '----------------DIFF ROOT----------------' );
return a.position.root.rootName < b.position.root.rootName ? -1 : 1;
}

// If change happens at the same position...
// // If change happens at the same position...
if ( a.position.isEqual( b.position ) ) {
console.log( a.changeCount + ' ' + a.type );
console.log( b.changeCount + ' ' + b.type );
console.log( '-------------' );
// Keep chronological order of operations.
if ( a.changeCount < b.changeCount ) {
console.log( '----------------IF----------------' );
Expand All @@ -435,16 +435,13 @@ export default class Differ {
console.log( '----------------ELSE----------------' );
return 1;
}
// return a.changeCount < b.changeCount ? -1 : 1;
}

// If positions differ, position "on the left" should be earlier in the result.
// return a.position.isBefore( b.position ) ? -1 : 1;
if ( a.position.isBefore( b.position ) ) {
console.log( '----------------BEFORE----------------' );
return -1;
} else {
console.log( '----------------AFTER----------------' );
return 1;
}
} );
Expand Down

0 comments on commit 0701ab4

Please sign in to comment.