diff --git a/src/IDF/Diff.php b/src/IDF/Diff.php index 8ab78b1..798b0a8 100644 --- a/src/IDF/Diff.php +++ b/src/IDF/Diff.php @@ -169,8 +169,7 @@ class IDF_Diff } $offsets[] = sprintf('
'.Pluf_esc($filename).' | '. @@ -354,31 +353,108 @@ class IDF_Diff if (IDF_FileUtil::isSupportedExtension($fileinfo[2])) { $pretty = ' prettyprint'; } - $out = ''; + $cc = 1; - $i = 0; + $left_offsets = array(); + $left_contents = array(); + $right_offsets = array(); + $right_contents = array(); + + $max_lineno_left = $max_lineno_right = 0; + foreach ($chunks as $chunk) { foreach ($chunk as $line) { - $line1 = ' '; - $line2 = ' '; - $line[2] = (strlen($line[2])) ? IDF_FileUtil::emphasizeControlCharacters(Pluf_esc($line[2])) : ' '; + $left = ''; + $right = ''; + $content = IDF_FileUtil::emphasizeControlCharacters(Pluf_esc($line[2])); + if ($line[0] and $line[1]) { - $class = 'diff-c'; - $line1 = $line2 = $line[2]; + $class = 'context'; + $left = $right = $content; } elseif ($line[0]) { - $class = 'diff-r'; - $line1 = $line[2]; + $class = 'removed'; + $left = $content; } else { - $class = 'diff-a'; - $line2 = $line[2]; + $class = 'added'; + $right = $content; } - $out .= sprintf('|||||
---|---|---|---|---|---|
%s | %s | %s | %s | %s | ', $line[0]); + $right_offsets[] = sprintf('%s | ', $line[1]); + $left_contents[] = sprintf('%s | ', $class, $pretty, $left); + $right_contents[] = sprintf('%s | ', $class, $pretty, $right); + + $max_lineno_left = max($max_lineno_left, $line[0]); + $max_lineno_right = max($max_lineno_right, $line[1]); + } + + if (count($chunks) > $cc) { + $left_offsets[] = '... | '; + $right_offsets[] = '... | '; + $left_contents[] = ''; + $right_contents[] = ' | '; } - if (count($chunks) > $cc) - $out .= ' |
... | ... |
'.Pluf_esc($filename).' | '. + '|||
---|---|---|---|
'.__('Old').' | '.__('New').' | ' . + '||
'. $inner_linecounts_left .' | '. "\n". + ''. $inner_contents_left .' | '. "\n".
+ ''. $inner_linecounts_right .' | '. "\n". + ''. $inner_contents_right .' | '. "\n".
+ '
+{if !$user.isAnonymous()}
+
+
+{/if}
{trans 'How to Participate in a Code Review'} + +{blocktrans}Code review is a process in which +after or before changes are commited into the code repository, +different people discuss the code changes. The goal is +to improve the quality of the code and the +contributions, as such, you must be pragmatic when writing +your review. Correctly mention the line numbers (in the old or in the +new file) and try to keep a good balance between seriousness and fun. +{/blocktrans} +{blocktrans} +Proposing code for review is intimidating, you know +you will receive critics, so please, as a reviewer, keep this +process fun, use it to help your contributor learn your +coding standards and the structure of the code and make them want +to propose more contributions. +{/blocktrans}
|
-{if !$user.isAnonymous()}
-
-
-{/if}
-{trans 'How to Participate in a Code Review'} - -{blocktrans}Code review is a process in which -after or before changes are commited into the code repository, -different people discuss the code changes. The goal is -to improve the quality of the code and the -contributions, as such, you must be pragmatic when writing -your review. Correctly mention the line numbers (in the old or in the -new file) and try to keep a good balance between seriousness and fun. -{/blocktrans} -{blocktrans} -Proposing code for review is intimidating, you know -you will receive critics, so please, as a reviewer, keep this -process fun, use it to help your contributor learn your -coding standards and the structure of the code and make them want -to propose more contributions. -{/blocktrans} |