Diff-Bugfix: don't repeat unchanged words
This commit is contained in:
parent
a6de228f56
commit
c3bd85e5ee
@ -760,17 +760,17 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._tokenizeHtml = function (str) {
|
this._tokenizeHtml = function (str) {
|
||||||
var splitArrayEntries = function (arr, by, prepend) {
|
var splitArrayEntriesEmbedSeparator = function (arr, by, prepend) {
|
||||||
var newArr = [];
|
var newArr = [];
|
||||||
for (var i = 0; i < arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i][0] == '<' && (by == " " || by == "\n")) {
|
if (arr[i][0] === '<' && (by === " " || by === "\n")) {
|
||||||
// Don't split HTML tags
|
// Don't split HTML tags
|
||||||
newArr.push(arr[i]);
|
newArr.push(arr[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parts = arr[i].split(by);
|
var parts = arr[i].split(by);
|
||||||
if (parts.length == 1) {
|
if (parts.length === 1) {
|
||||||
newArr.push(arr[i]);
|
newArr.push(arr[i]);
|
||||||
} else {
|
} else {
|
||||||
var j;
|
var j;
|
||||||
@ -793,10 +793,29 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
}
|
}
|
||||||
return newArr;
|
return newArr;
|
||||||
};
|
};
|
||||||
var arr = splitArrayEntries([str], '<', true);
|
var splitArrayEntriesSplitSeparator = function (arr, by) {
|
||||||
arr = splitArrayEntries(arr, '>', false);
|
var newArr = [];
|
||||||
arr = splitArrayEntries(arr, " ", false);
|
for (var i = 0; i < arr.length; i++) {
|
||||||
arr = splitArrayEntries(arr, "\n", false);
|
if (arr[i][0] === '<') {
|
||||||
|
newArr.push(arr[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var parts = arr[i].split(by);
|
||||||
|
for (var j = 0; j < parts.length; j++) {
|
||||||
|
if (j > 0) {
|
||||||
|
newArr.push(by);
|
||||||
|
}
|
||||||
|
newArr.push(parts[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newArr;
|
||||||
|
};
|
||||||
|
var arr = splitArrayEntriesEmbedSeparator([str], '<', true);
|
||||||
|
arr = splitArrayEntriesEmbedSeparator(arr, '>', false);
|
||||||
|
arr = splitArrayEntriesSplitSeparator(arr, " ");
|
||||||
|
arr = splitArrayEntriesSplitSeparator(arr, ".");
|
||||||
|
arr = splitArrayEntriesEmbedSeparator(arr, "\n", false);
|
||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -416,5 +416,21 @@ describe('linenumbering', function () {
|
|||||||
var diff = diffService.diff(before, after);
|
var diff = diffService.diff(before, after);
|
||||||
expect(diff).toBe('<P class="delete">Dann kam er zurück, klopfte an die Hausthür und rief \'macht auf, ihr lieben Kinder, eure Mutter ist da und hat jedem von Euch etwas mitgebarcht.\' Aber der Wolf hatte seine schwarze Pfote in das Fenster gelegt, das sahen die Kinder und riefen</P><P class="insert">(hier: Missbrauch von bewusstseinsverändernde Mittel - daher Zensiert)</P>');
|
expect(diff).toBe('<P class="delete">Dann kam er zurück, klopfte an die Hausthür und rief \'macht auf, ihr lieben Kinder, eure Mutter ist da und hat jedem von Euch etwas mitgebarcht.\' Aber der Wolf hatte seine schwarze Pfote in das Fenster gelegt, das sahen die Kinder und riefen</P><P class="insert">(hier: Missbrauch von bewusstseinsverändernde Mittel - daher Zensiert)</P>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not repeat the last word (1)', function () {
|
||||||
|
var before = "<P>sem. Nulla consequat massa quis enim. </P>",
|
||||||
|
after = "<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>";
|
||||||
|
var diff = diffService.diff(before, after);
|
||||||
|
|
||||||
|
expect(diff).toBe('<p>sem. Nulla consequat massa quis enim.<ins> TEST<br>' + "\n" + "TEST</ins></p>");
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not repeat the last word (2)', function () {
|
||||||
|
var before = "<P>...so frißt er Euch alle mit Haut und Haar.</P>",
|
||||||
|
after = "<p>...so frißt er Euch alle mit Haut und Haar und Augen und Därme und alles.</p>";
|
||||||
|
var diff = diffService.diff(before, after);
|
||||||
|
|
||||||
|
expect(diff).toBe("<p>...so frißt er Euch alle mit Haut und Haar<ins> und Augen und Därme und alles</ins>.</p>");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user