diff --git a/src/IDF/Diff.php b/src/IDF/Diff.php
index 8f10e7f..bfc273e 100644
--- a/src/IDF/Diff.php
+++ b/src/IDF/Diff.php
@@ -178,7 +178,6 @@ class IDF_Diff
$cc = 1;
$offsets = array();
$contents = array();
- $maxlinenum = 0;
foreach ($file['chunks'] as $chunk) {
foreach ($chunk as $line) {
@@ -195,8 +194,6 @@ class IDF_Diff
$content = Pluf_esc($content);
$content = self::makeNonPrintableCharsVisible($content);
$contents[] = sprintf('
%s | ', $class, $pretty, $content);
-
- $maxlinenum = max($maxlinenum, max($left, $right));
}
if (count($file['chunks']) > $cc) {
$offsets[] = '... | ... | ';
@@ -212,11 +209,23 @@ class IDF_Diff
'' ."\n";
$rows = count($offsets);
- $colwidth = (ceil(log10($maxlinenum)) + 1) * 10;
+
+ list($added, $removed) = end($file['chunks_def']);
+
+ $added = $added[0] + $added[1];
+ $leftwidth = 1;
+ if ($added > 0)
+ $leftwidth = (ceil(log10($added)) + 1) * 10;
+
+ $removed = $removed[0] + $removed[1];
+ $rightwidth = 1;
+ if ($removed > 0)
+ $rightwidth = (ceil(log10($removed)) + 1) * 10;
+
$first = array_shift($offsets);
$out .= '' ."\n".
- '' ."\n".
+ '' ."\n".
''.
''.Pluf_esc($filename).' | '.
'
' ."\n".