Date: Sun, 17 Feb 2019 19:39:05 +0100
Subject: [PATCH] Diff-Bugfix: Newlines and split paragraphs
---
.../app/core/ui-services/diff.service.spec.ts | 18 ++++++++++++++++++
.../src/app/core/ui-services/diff.service.ts | 4 ++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/client/src/app/core/ui-services/diff.service.spec.ts b/client/src/app/core/ui-services/diff.service.spec.ts
index 4fdcc2db5..38c373aee 100644
--- a/client/src/app/core/ui-services/diff.service.spec.ts
+++ b/client/src/app/core/ui-services/diff.service.spec.ts
@@ -809,6 +809,24 @@ describe('DiffService', () => {
);
}));
+ it('does not like splitting paragraphs too much, but respects line breaks between paragraphs', inject(
+ [DiffService],
+ (service: DiffService) => {
+ const before =
+ 'Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher. Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.
',
+ after =
+ 'Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.
\nDes so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.';
+ const diff = service.diff(before, after);
+
+ expect(diff).toBe(
+ '
Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher. Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.
' +
+ 'Bavaria ipsum dolor sit amet o’ha wea nia ausgähd, kummt nia hoam i hob di narrisch gean helfgod ebba ded baddscher.
' +
+ '\n' +
+ 'Des so so, nia Biawambn back mas? Kaiwe Hetschapfah Trachtnhuat, a bravs.
'
+ );
+ }
+ ));
+
it('does not repeat the last word (1)', inject([DiffService], (service: DiffService) => {
const before = 'sem. Nulla consequat massa quis enim.
',
after = 'sem. Nulla consequat massa quis enim. TEST
\nTEST
';
diff --git a/client/src/app/core/ui-services/diff.service.ts b/client/src/app/core/ui-services/diff.service.ts
index b42adeab3..865ed04dc 100644
--- a/client/src/app/core/ui-services/diff.service.ts
+++ b/client/src/app/core/ui-services/diff.service.ts
@@ -940,8 +940,8 @@ export class DiffService {
private diffDetectBrokenDiffHtml(html: string): boolean {
// If other HTML tags are contained within INS/DEL (e.g. "Test