From 7d806325579547facd27a0c44b54872fe9d7fb2d Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Fri, 1 Aug 2008 00:50:44 +0200 Subject: [PATCH] Added code indentation. --- src/IDF/Diff.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/IDF/Diff.php b/src/IDF/Diff.php index ca5f25f..9a078e6 100644 --- a/src/IDF/Diff.php +++ b/src/IDF/Diff.php @@ -113,7 +113,8 @@ class IDF_Diff } else { $class = 'diff-a'; } - $out .= sprintf('%s%s%s'."\n", $line[0], $line[1], $class, Pluf_esc($line[2])); + $line_content = $this->padLine(Pluf_esc($line[2])); + $out .= sprintf('%s%s%s'."\n", $line[0], $line[1], $class, $line_content); } if (count($file['chunks']) > $cc) $out .= '...... '."\n"; @@ -124,6 +125,18 @@ class IDF_Diff return $out; } + + public function padLine($line) + { + $n = strlen($line); + for ($i=0;$i<$n;$i++) { + if (substr($line, $i, 1) != ' ') { + break; + } + } + return str_repeat(' ', $i).substr($line, $i); + } + /** * @return array array(array(start, n), array(start, n)) */