diff --git a/_test/cases/inc/DifferenceEngine.test.php b/_test/cases/inc/DifferenceEngine.test.php new file mode 100644 index 0000000000000000000000000000000000000000..294f0e6e332f2084aa859adf70f320e786fb0e87 --- /dev/null +++ b/_test/cases/inc/DifferenceEngine.test.php @@ -0,0 +1,31 @@ +<?php +require_once DOKU_INC.'inc/DifferenceEngine.php'; + +class differenceengine_test extends UnitTestCase { + + function test_white_between_words(){ + // From FS#2161 + global $lang; + + $df = new Diff(explode("\n","example"), + explode("\n","example example2")); + + $idf = new InlineDiffFormatter(); + $tdf = new TableDiffFormatter(); + + $this->assertEqual($idf->format($df), '<tr><td colspan="4" class="diff-blockheader">@@ ' . $lang['line'] . + ' -1 +1 @@ <span class="diff-deletedline"><del>' . $lang['deleted'] . + '</del></span> <span class="diff-addedline">' . $lang['created'] . + '</span></td></tr> + +<tr><td colspan="4">example <span class="diff-addedline">example2</span></td></tr> +'); + $this->assertEqual($tdf->format($df), + '<tr><td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td> + <td class="diff-blockheader" colspan="2">' . $lang['line'] . ' 1:</td> +</tr> +<tr><td>-</td><td class="diff-deletedline">example</td><td>+</td><td class="diff-addedline">example <strong>example2</strong></td></tr> +'); + } +} +//Setup VIM: ex: et ts=4 : diff --git a/inc/DifferenceEngine.php b/inc/DifferenceEngine.php index 36322d22278674f683b1703c680d0cec2c879a46..906a17b2d34d48915e91aea01f5a009051e82f13 100644 --- a/inc/DifferenceEngine.php +++ b/inc/DifferenceEngine.php @@ -943,7 +943,7 @@ class InlineWordLevelDiff extends MappedDiff { $orig = new _HWLDF_WordAccumulator; foreach ($this->edits as $edit) { if ($edit->type == 'copy') - $orig->addWords($edit->orig); + $orig->addWords($edit->closing); elseif ($edit->type == 'change'){ $orig->addWords($edit->orig, 'del'); $orig->addWords($edit->closing, 'add');