Fix a bug where a single moved word was not highlighted in the diff
This commit is contained in:
parent
c5be76ace2
commit
029ca0b8e3
@ -863,18 +863,33 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currOldRow = 0;
|
||||||
for (i = 0; i < out.n.length; i++) {
|
for (i = 0; i < out.n.length; i++) {
|
||||||
if (out.n[i].text === undefined) {
|
if (out.n[i].text === undefined) {
|
||||||
if (out.n[i] !== "") {
|
if (out.n[i] !== "") {
|
||||||
str += '<ins>' + out.n[i] + "</ins>";
|
str += '<ins>' + out.n[i] + "</ins>";
|
||||||
}
|
}
|
||||||
|
} else if (out.n[i].row < currOldRow) {
|
||||||
|
str += '<ins>' + out.n[i].text + "</ins>";
|
||||||
} else {
|
} else {
|
||||||
var pre = "";
|
var pre = "";
|
||||||
|
|
||||||
for (var j = out.n[i].row + 1; j < out.o.length && out.o[j].text === undefined; j++) {
|
if ((i + 1) < out.n.length && out.n[i + 1].row !== undefined && out.n[i + 1].row > out.n[i].row + 1) {
|
||||||
pre += '<del>' + out.o[j] + "</del>";
|
for (var n = out.n[i].row + 1; n < out.n[i + 1].row; n++) {
|
||||||
|
if (out.o[n].text === undefined) {
|
||||||
|
pre += '<del>' + out.o[n] + "</del>";
|
||||||
|
} else {
|
||||||
|
pre += '<del>' + out.o[n].text + "</del>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var j = out.n[i].row + 1; j < out.o.length && out.o[j].text === undefined; j++) {
|
||||||
|
pre += '<del>' + out.o[j] + "</del>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
str += out.n[i].text + pre;
|
str += out.n[i].text + pre;
|
||||||
|
|
||||||
|
currOldRow = out.n[i].row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,6 +479,14 @@ describe('linenumbering', function () {
|
|||||||
|
|
||||||
expect(diff).toBe('<P class="delete">...so frißt er Euch alle mit Haut und Haar.</P><P class="insert">...so frißt er <SPAN style="font-size: 2em; opacity: 0.5">Euch alle</SPAN> mit Haut und Haar.</P>');
|
expect(diff).toBe('<P class="delete">...so frißt er Euch alle mit Haut und Haar.</P><P class="insert">...so frißt er <SPAN style="font-size: 2em; opacity: 0.5">Euch alle</SPAN> mit Haut und Haar.</P>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('marks a single moved word as deleted and inserted again', function () {
|
||||||
|
var before = '<p>tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren bla, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>',
|
||||||
|
after = '<p>tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd bla, no sea takimata sanctus est Lorem ipsum dolor gubergren sit amet.</p>';
|
||||||
|
var diff = diffService.diff(before, after);
|
||||||
|
|
||||||
|
expect(diff).toBe('<p>tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd <del>gubergren </del>bla, no sea takimata sanctus est Lorem ipsum dolor <ins>gubergren </ins>sit amet.</p>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ignoring line numbers', function () {
|
describe('ignoring line numbers', function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user