From c7729a66193d895f772137c61b0ad934d42f4ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Ho=CC=88=C3=9Fl?= Date: Sun, 21 Jan 2018 12:52:43 +0100 Subject: [PATCH] Diff-Bugfix: Whitespace was inserted after
--- CHANGELOG | 2 +- openslides/motions/static/js/motions/diff.js | 3 +++ tests/karma/motions/diff.service.test.js | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c2ad735d6..920e4611e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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, #3537, #3546]. + #3440, #3450, #3465, #3537, #3546, #3548]. - Added inline Editing for motion reason [#3361]. - Added multiselect filter for motion comments [#3372]. - Added support for pinning personal notes to the window [#3360]. diff --git a/openslides/motions/static/js/motions/diff.js b/openslides/motions/static/js/motions/diff.js index 028a84a56..a9da86782 100644 --- a/openslides/motions/static/js/motions/diff.js +++ b/openslides/motions/static/js/motions/diff.js @@ -675,6 +675,9 @@ angular.module('OpenSlidesApp.motions.diff', ['OpenSlidesApp.motions.lineNumberi for (var ent in entities) { html = html.replace(new RegExp(ent, 'g'), entities[ent]); } + + // Newline characters: after closing block-level-elements, but not after BR (which is inline) + html = html.replace(/(
)\n/gi, "$1"); html = html.replace(/[ \n\t]+/gi, ' '); html = html.replace(/(<\/(div|p|ul|li|blockquote>)>) /gi, "$1\n"); diff --git a/tests/karma/motions/diff.service.test.js b/tests/karma/motions/diff.service.test.js index d5452c7bd..adbfb6b32 100644 --- a/tests/karma/motions/diff.service.test.js +++ b/tests/karma/motions/diff.service.test.js @@ -423,6 +423,14 @@ describe('linenumbering', function () { expect(diff).toBe('The brown spotted fox jumleaped over the rolling log.'); }); + it('does not insert spaces after a unchanged BR tag', function() { + var before = "

" + noMarkup(1) + "Hendl Kirwa hod Maßkruag
" + noMarkup(2) + "gmahde Wiesn

", + after = "

Hendl Kirwa hod Maßkruag
\ngmahde Wiesn

"; + var diff = diffService.diff(before, after); + + expect(diff).toBe(before); + }); + it('does not mark the last line of a paragraph as change if a long new one is appended', function () { var before = "

 Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

", after = "

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

\n" + @@ -534,7 +542,7 @@ describe('linenumbering', function () { after = "

sem. Nulla consequat massa quis enim. TEST
\nTEST

"; var diff = diffService.diff(before, after); - expect(diff).toBe('

sem. Nulla consequat massa quis enim. TEST
TEST

'); + expect(diff).toBe('

sem. Nulla consequat massa quis enim. TEST
TEST

'); }); it('does not repeat the last word (2)', function () {