Fixes an edge case in the diff
This commit is contained in:
parent
ced36d0c0d
commit
e4da7905ca
@ -38,7 +38,7 @@ Motions:
|
||||
- Bugfix: Several bugfixes regarding splitting list items in
|
||||
change recommendations [#3288].
|
||||
- Bugfix: Several bugfixes regarding diff version [#3407, #3408, #3410,
|
||||
#3440, #3450, #3465].
|
||||
#3440, #3450, #3465, #3537, #3546].
|
||||
- Added inline Editing for motion reason [#3361].
|
||||
- Added multiselect filter for motion comments [#3372].
|
||||
- Added support for pinning personal notes to the window [#3360].
|
||||
|
@ -960,6 +960,19 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
||||
newStr = this._normalizeHtmlForDiff(newStr.replace(/\s+$/, '').replace(/^\s+/, ''));
|
||||
|
||||
var out = this._diff(this._tokenizeHtml(oldStr), this._tokenizeHtml(newStr));
|
||||
|
||||
// This fixes the problem tested by "does not lose words when changes are moved X-wise"
|
||||
var lastRow = 0;
|
||||
for (var z = 0; z < out.n.length; z++) {
|
||||
if (out.n[z].row && out.n[z].row > lastRow) {
|
||||
lastRow = out.n[z].row;
|
||||
}
|
||||
if (out.n[z].row && out.n[z].row < lastRow) {
|
||||
out.o[out.n[z].row] = out.o[out.n[z].row].text;
|
||||
out.n[z] = out.n[z].text;
|
||||
}
|
||||
}
|
||||
|
||||
var str = "";
|
||||
var i;
|
||||
|
||||
|
@ -598,6 +598,14 @@ describe('linenumbering', function () {
|
||||
|
||||
expect(diff).toBe('<p class="os-split-after os-split-before"><span class="line-number-4 os-line-number" contenteditable="false" data-line-number="4"> </span><span class="os-split-after os-split-before" style="color: #0000ff;">sanctus est Lorem ipsum dolor sit amet. <ins>Test </ins>Lorem ipsum dolor sit amet, consetetur sadipscing </span></p>');
|
||||
});
|
||||
|
||||
it('does not lose words when changes are moved X-wise', function () {
|
||||
var before = 'elitr. einsetzt. VERSCHLUCKT noch die sog. Gleichbleibend (Wird gelöscht).',
|
||||
after = 'elitr, Einfügung durch Änderung der Gleichbleibend, einsetzt.';
|
||||
|
||||
var diff = diffService.diff(before, after);
|
||||
expect(diff).toBe('elitr<del>. einsetzt. VERSCHLUCKT noch die sog.</del><ins>, Einfügung durch Änderung der</ins> Gleichbleibend<del> (Wird gelöscht).</del><ins>, einsetzt.</ins>');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ignoring line numbers', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user