Action diffs after 0ms and handle wrapped lines

Need to call updateDiffs after 0ms as char change hasn't yet registered
Add on the extra heights for wrapped lines per line number
This commit is contained in:
Matt Pass
2015-05-23 11:23:23 +01:00
parent 05996618d7
commit 55cccdecc9
2 changed files with 68 additions and 54 deletions

View File

@@ -361,7 +361,8 @@ var ICEcoder = {
}
// Update diffs if we have a split pane
if (top.ICEcoder.splitPane) {
top.ICEcoder.updateDiffs();
// Need 0ms tickover so we handle char change first
setTimeout(function(){top.ICEcoder.updateDiffs();},0);
}
// Update HTML edited files live
if (filepath && top.ICEcoder.previewWindow.location) {
@@ -474,6 +475,12 @@ var ICEcoder = {
if (opcodes[i][0] == "replace") {
// Line amount is diff between end of both panes at this point in our loop, plus 1 line and our overall document shift, multiplied by font size
amt = ((opcodes[i][4] - opcodes[i][2] + 1 + top.ICEcoder.renderPaneShiftAmount) * cM.defaultTextHeight());
// Add on the extra heights for any wrapped lines
for (var j=opcodes[i][4]-1; j<=opcodes[i][2]-1; j++) {
if (cMdiff.getLineHandle(j).height > cM.defaultTextHeight()) {
amt += cMdiff.getLineHandle(j).height - cM.defaultTextHeight();
}
}
// If we have an height greater than the default text height, add a new style
if (amt > cM.defaultTextHeight()) {
top.ICEcoder.renderLineStyle.push(["main", opcodes[i][2], "height", amt + "px"]);
@@ -505,6 +512,12 @@ var ICEcoder = {
if (opcodes[i][0] == "replace") {
// Line amount is diff between end of both panes at this point in our loop, plus 1 line and our overall document shift, multiplied by font size
amt = ((opcodes[i][2] - opcodes[i][4] + 1 - top.ICEcoder.renderPaneShiftAmount) * cM.defaultTextHeight());
// Add on the extra heights for any wrapped lines
for (var j=opcodes[i][4]-1; j<=opcodes[i][2]-1; j++) {
if (cM.getLineHandle(j).height > cM.defaultTextHeight()) {
amt += cM.getLineHandle(j).height - cM.defaultTextHeight();
}
}
// If we have an height greater than the default text height, add a new style
if (amt > cM.defaultTextHeight()) {
top.ICEcoder.renderLineStyle.push(["diff", opcodes[i][4], "height", amt + "px"]);