Fixes rendering issue.

This commit is contained in:
Jamie Peabody
2014-01-25 12:24:01 +00:00
parent b436e6d5ff
commit bf96bc51a1
6 changed files with 46 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@@ -73,11 +73,11 @@ jQuery.extend(Mgly.LCS.prototype, {
}
if (change.op != 'd') {
// find the starting index of the line
li = d.getLines('lhs').slice(0, change['rhs-line-from']).join(' ').length;
li = d.getLines('rhs').slice(0, change['rhs-line-from']).join(' ').length;
// get the index of the the span of the change
lj = change['rhs-line-to'] + 1;
// get the changed text
var rchange = d.getLines('lhs').slice(change['rhs-line-from'], lj).join(' ');
var rchange = d.getLines('rhs').slice(change['rhs-line-from'], lj).join(' ');
if (change.op == 'a') rchange += ' ';// include the leading space
else if (li > 0 && change.op == 'c') li += 1; // ignore leading space if not first word
// output the changed index and text
@@ -181,14 +181,17 @@ jQuery.extend(Mgly.diff.prototype, {
else if (item.rhs_inserted_count == 0) rhs_str = item.rhs_start;
else rhs_str = (item.rhs_start + 1) + ',' + (item.rhs_start + item.rhs_inserted_count);
nf += lhs_str + change + rhs_str + '\n';
if (this.rhs_lines && this.lhs_lines) {
var lhs_lines = this.getLines('lhs');
var rhs_lines = this.getLines('rhs');
if (rhs_lines && lhs_lines) {
// if rhs/lhs lines have been retained, output contextual diff
for (var i = item.lhs_start; i < item.lhs_start + item.lhs_deleted_count; ++i) {
nf += '< ' + this.lhs_lines[i] + '\n';
nf += '< ' + lhs_lines[i] + '\n';
}
if (item.rhs_inserted_count && item.lhs_deleted_count) nf += '---\n';
for (var i = item.rhs_start; i < item.rhs_start + item.rhs_inserted_count; ++i) {
nf += '> ' + this.rhs_lines[i] + '\n';
nf += '> ' + rhs_lines[i] + '\n';
}
}
}

6
lib/mergely.min.js vendored

File diff suppressed because one or more lines are too long