1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Merge pull request #224 from github/fix-ranges-following-asymmetric-patches

Fix ranges following asymmetric patches
This commit is contained in:
Josh Vera 2015-11-06 10:41:48 -05:00
commit 29ecb1cd70

16
prototype/UI/diff.js vendored
View File

@ -234,21 +234,29 @@ function rollToDOM(sources, rollOrTerm, getRangeFun, diffToDOMFun) {
if (childRange.before != null) {
var beforeRange = childRange.before;
var li = wrap("li", beforeAfterChild.before);
if (beforeAfterChild.before.classList.contains("invisible")) {
li.classList.add("invisible");
} else {
var beforeSeparator = sources.before.substr(previousBefore, beforeRange[0] - previousBefore);
elementA.appendChild(document.createTextNode(beforeSeparator));
elementA.appendChild(wrap("li", beforeAfterChild.before));
previousBefore = beforeRange[0] + beforeRange[1];
}
elementA.appendChild(li);
}
if (childRange.after != null) {
var afterRange = childRange.after;
var li = wrap("li", beforeAfterChild.after);
if (beforeAfterChild.after.classList.contains("invisible")) {
li.classList.add("invisible");
} else {
var afterSeparator = sources.after.substr(previousAfter, afterRange[0] - previousAfter);
elementB.appendChild(document.createTextNode(afterSeparator));
elementB.appendChild(wrap("li", beforeAfterChild.after));
previousAfter = afterRange[0] + afterRange[1];
}
elementB.appendChild(li);
}
}
var beforeText = sources.before.substr(previousBefore, range.before[0] + range.before[1] - previousBefore);
var afterText = sources.after.substr(previousAfter, range.after[0] + range.after[1] - previousAfter);