Summary: DiffRenderSource should collapse adjacent inline insertions and deletions
Created: 2010-05-10 06:35
Status: Closed - added for 2.2.17
Category: Feature
Priority: 5
Version: 2.2.12+

Description: With $EnableDiffInline set (by default from 2.2.13), DiffRenderSource will do word-level highlighting for changes. Quite often this will display the modification of adjacent words as separate diffs, with output such as "<ins>new</ins> <ins>words</ins>" instead of "<ins>new words</ins>".

These adjacent additions or removals should be combined, eg. with the following modification:

Index: pagerev.php
--- pagerev.php	(revision 2555)
+++ pagerev.php	(working copy)
@@ -198,6 +198,7 @@
   $z2[0] = $line.$z2[0];
   foreach ($cnt as $a) $lines[] = implode('', array_slice($z2, $a[0], $a[1]));
   $ret = trim(implode("\n", $lines));
+  $ret = preg_replace('!</(del|ins)> <\1>!', ' ', $ret);
   return str_replace("\n","<br />",$ret);
 ## Split a line into pieces before passing it through `diff`