mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-26 19:56:49 +00:00
Used a more robust heuristic for merging consecutive diffs
- Check if consecutive diffs are separate by 1 word in addition to max 3 chars. This takes care of diffs introduced by template diffs separated by the template name and creates a clean single diff. Change-Id: I9181d2ed9a07bee6ca5d5ebd6ddea84f7e2cecac
This commit is contained in:
parent
2bc066b42d
commit
f8221b128b
|
@ -149,24 +149,25 @@ var refineDiff = function( diff ) {
|
|||
var newDiffs = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
var d = wordDiffs[i];
|
||||
var dVal = d.value;
|
||||
if (d.added) {
|
||||
// Attempt to accumulate
|
||||
if (currIns === null) {
|
||||
currIns = d;
|
||||
} else {
|
||||
currIns.value = currIns.value + d.value;
|
||||
currIns.value = currIns.value + dVal;
|
||||
}
|
||||
} else if (d.removed) {
|
||||
// Attempt to accumulate
|
||||
if (currDel === null) {
|
||||
currDel = d;
|
||||
} else {
|
||||
currDel.value = currDel.value + d.value;
|
||||
currDel.value = currDel.value + dVal;
|
||||
}
|
||||
} else if ((d.value.length < 4) && currIns && currDel) {
|
||||
} else if (((dVal.length < 4) || !dVal.match(/\s/)) && currIns && currDel) {
|
||||
// Attempt to accumulate
|
||||
currIns.value = currIns.value + d.value;
|
||||
currDel.value = currDel.value + d.value;
|
||||
currIns.value = currIns.value + dVal;
|
||||
currDel.value = currDel.value + dVal;
|
||||
} else {
|
||||
// Accumulation ends. Purge!
|
||||
if (currIns !== null) {
|
||||
|
|
Loading…
Reference in a new issue