Disable change ratio detection / Fix for marking unchanged line as changed
This commit is contained in:
parent
721064700a
commit
e651c124e4
@ -37,7 +37,8 @@ Motions:
|
|||||||
- Added config value for pagenumber alignment in PDF [#3327].
|
- Added config value for pagenumber alignment in PDF [#3327].
|
||||||
- Bugfix: Several bugfixes regarding splitting list items in
|
- Bugfix: Several bugfixes regarding splitting list items in
|
||||||
change recommendations [#3288].
|
change recommendations [#3288].
|
||||||
- Bugfix: Several bugfixes regarding diff version [#3407, #3408, #3410, #3440].
|
- Bugfix: Several bugfixes regarding diff version [#3407, #3408, #3410,
|
||||||
|
#3440, #3450].
|
||||||
- Added inline Editing for motion reason [#3361].
|
- Added inline Editing for motion reason [#3361].
|
||||||
- Added multiselect filter for motion comments [#3372].
|
- Added multiselect filter for motion comments [#3372].
|
||||||
- Added support for pinning personal notes to the window [#3360].
|
- Added support for pinning personal notes to the window [#3360].
|
||||||
|
@ -1002,29 +1002,6 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
return str.replace(/^\s+/g, '').replace(/\s+$/g, '').replace(/ {2,}/g, ' ');
|
return str.replace(/^\s+/g, '').replace(/\s+$/g, '').replace(/ {2,}/g, ' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the ratio of the text affected by inline diff
|
|
||||||
* From 0 (no changes at all) to 1 (everything has changed)
|
|
||||||
*
|
|
||||||
* @param html
|
|
||||||
* @returns {number}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this._calcChangeRatio = function(html) {
|
|
||||||
var lengthChanged = 0;
|
|
||||||
|
|
||||||
html = html.replace(/<del>(.*?)<\/del>/gi, function() { lengthChanged += arguments[1].length; return ""; });
|
|
||||||
html = html.replace(/<ins>(.*?)<\/ins>/gi, function() { lengthChanged += arguments[1].length; return ""; });
|
|
||||||
html = html.replace(/<.*?>/, "").trim();
|
|
||||||
|
|
||||||
var lengthRemaining = html.length;
|
|
||||||
if (lengthRemaining === 0 && lengthChanged === 0) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return (lengthChanged / (lengthChanged + lengthRemaining));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {string} html
|
* @param {string} html
|
||||||
@ -1066,12 +1043,6 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If too much of the text is changed, it's better to separate the old from new new version,
|
|
||||||
// otherwise the result looks strange
|
|
||||||
if (this._calcChangeRatio(html) > 0.66) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If non of the conditions up to now is met, we consider the diff as being sane
|
// If non of the conditions up to now is met, we consider the diff as being sane
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -423,20 +423,14 @@ describe('linenumbering', function () {
|
|||||||
expect(diff).toBe('The <strong>brown</strong> spotted fox <del>jum</del><ins>lea</ins>ped over the rolling log.');
|
expect(diff).toBe('The <strong>brown</strong> spotted fox <del>jum</del><ins>lea</ins>ped over the rolling log.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('too many changes result in separate paragraphs', function () {
|
it('does not mark the last line of a paragraph as change if a long new one is appended', function () {
|
||||||
var before = "<p>Test1 Test2 Test3 Test4 Test5 Test9</p>",
|
var before = "<p><span class=\"os-line-number line-number-5\" data-line-number=\"5\" contenteditable=\"false\"> </span>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>",
|
||||||
after = "<p>Test1 Test6 Test7 Test8 Test9</p>";
|
after = "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>\n" +
|
||||||
var diff = diffService.diff(before, after);
|
"\n" +
|
||||||
|
"<p>Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</p>";
|
||||||
expect(diff).toBe('<P class="delete">Test1 Test2 Test3 Test4 Test5 Test9</P><P class="insert">Test1 Test6 Test7 Test8 Test9</P>');
|
var diff = diffService.diff(before, after);
|
||||||
});
|
expect(diff).toBe("<p><span class=\"line-number-5 os-line-number\" contenteditable=\"false\" data-line-number=\"5\"> </span>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>\n" +
|
||||||
|
"<p><ins>Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.</ins></p>");
|
||||||
it('too many changes result in separate paragraphs - special case with un-wrapped text', function () {
|
|
||||||
var before = "Test1 Test2 Test3 Test4 Test5 Test9",
|
|
||||||
after = "Test1 Test6 Test7 Test8 Test9";
|
|
||||||
var diff = diffService.diff(before, after);
|
|
||||||
|
|
||||||
expect(diff).toBe('<DEL>Test1 Test2 Test3 Test4 Test5 Test9</DEL><INS>Test1 Test6 Test7 Test8 Test9</INS>');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not result in separate paragraphs when only the first word has changed', function () {
|
it('does not result in separate paragraphs when only the first word has changed', function () {
|
||||||
@ -523,13 +517,6 @@ describe('linenumbering', function () {
|
|||||||
expect(diff).toBe("<P class=\"delete\">Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.</P>");
|
expect(diff).toBe("<P class=\"delete\">Ihr könnt ohne Sorge fortgehen.'Da meckerte die Alte und machte sich getrost auf den Weg.</P>");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not perform inline diff if there are too many changes', function () {
|
|
||||||
var before = "<P>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>",
|
|
||||||
after = "<p>(hier: Missbrauch von bewusstseinsverändernde Mittel - daher Zensiert)</p>";
|
|
||||||
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>');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not repeat the last word (1)', function () {
|
it('does not repeat the last word (1)', function () {
|
||||||
var before = "<P>sem. Nulla consequat massa quis enim. </P>",
|
var before = "<P>sem. Nulla consequat massa quis enim. </P>",
|
||||||
after = "<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>";
|
after = "<p>sem. Nulla consequat massa quis enim. TEST<br>\nTEST</p>";
|
||||||
|
Loading…
Reference in New Issue
Block a user