Skip to content

Commit a0b906b

Browse files
committed
Prefer the new if we can only show either old or new
Signed-off-by: Jack Cherng <[email protected]>
1 parent 062b5ed commit a0b906b

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/Renderer/Html/AbstractHtml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract class AbstractHtml extends AbstractRenderer
2323
const IS_TEXT_RENDERER = false;
2424

2525
/**
26-
* @var array array of the different opcodes and how they are mapped to HTML classes
26+
* @var string[] array of the different opcodes and how they are mapped to HTML classes
2727
*
2828
* @todo rename to OP_CLASS_MAP in v7
2929
*/

src/Renderer/Html/Combined.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,11 @@ protected function renderTableBlockEqual(array $block): string
126126
// note that although we are in a OP_EQ situation,
127127
// the old and the new may not be exactly the same
128128
// because of ignoreCase, ignoreWhitespace, etc
129-
foreach ($block['old']['lines'] as $oldLine) {
130-
// hmm... but there is only space for one line
131-
// we could only pick either the old or the new to show
129+
foreach ($block['new']['lines'] as $newLine) {
130+
// but in this renderer, we can only pick either the old or the new to show
132131
$html .=
133132
'<tr data-type="=">' .
134-
'<td class="old">' . $oldLine . '</td>' .
133+
'<td class="new">' . $newLine . '</td>' .
135134
'</tr>';
136135
}
137136

src/Renderer/Html/Inline.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ protected function renderTableBlockEqual(array $block): string
134134
// the old and the new may not be exactly the same
135135
// because of ignoreCase, ignoreWhitespace, etc
136136
foreach ($block['new']['lines'] as $no => $newLine) {
137-
// hmm... but there is only space for one line
138-
// we could only pick either the old or the new to show
137+
// but in this renderer, we can only pick either the old or the new to show
139138
$oldLineNum = $block['old']['offset'] + $no + 1;
140139
$newLineNum = $block['new']['offset'] + $no + 1;
141140

src/Renderer/Text/Unified.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ protected function renderWorker(Differ $differ): string
4444
$ret .= $this->renderHunkHeader($i1 + 1, $i2 - $i1, $j1 + 1, $j2 - $j1);
4545

4646
foreach ($hunk as [$op, $i1, $i2, $j1, $j2]) {
47+
// note that although we are in a OP_EQ situation,
48+
// the old and the new may not be exactly the same
49+
// because of ignoreCase, ignoreWhitespace, etc
4750
if ($op === SequenceMatcher::OP_EQ) {
51+
// we could only pick either the old or the new to show
4852
$ret .= $this->renderContext(' ', $differ->getNew($j1, $j2));
4953

5054
continue;

0 commit comments

Comments
 (0)