vendor/assets/javascripts/codemirror/addons/merge/merge.js in codemirror-rails-3.22 vs vendor/assets/javascripts/codemirror/addons/merge/merge.js in codemirror-rails-3.23
- old
+ new
@@ -80,10 +80,14 @@
}
set(true);
}
dv.edit.on("change", change);
dv.orig.on("change", change);
+ dv.edit.on("markerAdded", set);
+ dv.edit.on("markerCleared", set);
+ dv.orig.on("markerAdded", set);
+ dv.orig.on("markerCleared", set);
dv.edit.on("viewportChange", set);
dv.orig.on("viewportChange", set);
update();
return update;
}
@@ -347,10 +351,16 @@
rightOriginal: function() { return this.right && this.right.orig; },
leftOriginal: function() { return this.left && this.left.orig; },
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);
}
};
function asString(obj) {
if (typeof obj == "string") return obj;
@@ -395,9 +405,18 @@
moveOver(tp == DIFF_INSERT ? edit : orig, part[1]);
}
}
if (startEdit <= edit.line || startOrig <= orig.line)
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];