Skip to content

Commit c75a2f4

Browse files
committed
Properly add -- before/after different lines
1 parent 1854a43 commit c75a2f4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

run-tests.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,8 +2960,10 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
29602960
}
29612961
if ($end - $context_line_count > $old_k1) {
29622962
$old_k1 = $end - $context_line_count;
2963-
// Add a '--' to mark sections where the common areas were truncated
2964-
$diff[] = '--';
2963+
if ($old_k1 > 0) {
2964+
// Add a '--' to mark sections where the common areas were truncated
2965+
$diff[] = '--';
2966+
}
29652967
}
29662968
$old_k1 = max($old_k1, 0);
29672969
while ($old_k1 < $end) {
@@ -3007,6 +3009,10 @@ function generate_array_diff(array $ar1, array $ar2, bool $is_reg, array $w): ar
30073009
$diff[] = sprintf("{$line_number_spec}+ ", $idx2 + 1) . $ar2[$idx2++];
30083010
}
30093011
$add_context_lines(min($old_k1 + $context_line_count + 1, $cnt1 + 1));
3012+
if ($old_k1 < $cnt1 + 1) {
3013+
// Add a '--' to mark sections where the common areas were truncated
3014+
$diff[] = '--';
3015+
}
30103016

30113017
return $diff;
30123018
}

0 commit comments

Comments
 (0)