File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ protected function renderTableBlockReplace(array $block): string
239239 $ this ->renderTableBlockDelete ($ block ) .
240240 $ this ->renderTableBlockInsert ($ block );
241241
242- continue ;
242+ break ;
243243 }
244244
245245 $ ret .= $ this ->renderTableRow ('rep ' , SequenceMatcher::OP_REP , $ mergedLine );
Original file line number Diff line number Diff line change @@ -45,4 +45,27 @@ public function testHtmlEscapeForOpEq(): void
4545 static ::assertStringNotContainsString ('<tag> ' , $ result );
4646 static ::assertStringNotContainsString ('</tag> ' , $ result );
4747 }
48+
49+ /**
50+ * Test unmerge-able block.
51+ *
52+ * @see https://github.com/jfcherng/php-diff/issues/69
53+ */
54+ public function testSimpleUnmergeableBlock (): void
55+ {
56+ $ result = DiffHelper::calculate ("111 \n222 \n333 \n" , "444 \n555 \n666 \n" , 'Combined ' );
57+
58+ static ::assertSame (
59+ [1 , 1 , 1 , 1 , 1 , 1 ],
60+ [
61+ substr_count ($ result , '111 ' ),
62+ substr_count ($ result , '222 ' ),
63+ substr_count ($ result , '333 ' ),
64+ substr_count ($ result , '444 ' ),
65+ substr_count ($ result , '555 ' ),
66+ substr_count ($ result , '666 ' ),
67+ ],
68+ "Unmerge-able block shouldn't be repeated. " ,
69+ );
70+ }
4871}
You can’t perform that action at this time.
0 commit comments