Skip to content

Commit

Permalink
[merge addon] Add leftChunks and rightChunks methods
Browse files Browse the repository at this point in the history
Issue #2334
  • Loading branch information
marijnh committed Mar 9, 2014
1 parent 809fe26 commit a21c491
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions addon/merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@
setShowDifferences: function(val) {
if (this.right) this.right.setShowDifferences(val);
if (this.left) this.left.setShowDifferences(val);
},
rightChunks: function() {
return this.right && getChunks(this.right.diff);
},
leftChunks: function() {
return this.left && getChunks(this.left.diff);
}
};

Expand Down Expand Up @@ -403,6 +409,15 @@
f(startOrig, orig.line + 1, startEdit, edit.line + 1);
}

function getChunks(diff) {
var collect = [];
iterateChunks(diff, function(topOrig, botOrig, topEdit, botEdit) {
collect.push({origFrom: topOrig, origTo: botOrig,
editFrom: topEdit, editTo: botEdit});
});
return collect;
}

function endOfLineClean(diff, i) {
if (i == diff.length - 1) return true;
var next = diff[i + 1][1];
Expand Down

0 comments on commit a21c491

Please sign in to comment.