Skip to content

Commit 03c386e

Browse files
Bugfix for #366
1 parent 1af2be4 commit 03c386e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

diff-so-fancy

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,19 @@ sub mark_empty_line {
375375
my $reset_color = "\e\\[0?m";
376376
my $reset_escape = "\e\[m";
377377
my $invert_color = "\e\[7m";
378-
379-
$line =~ s/^($ansi_color_regex)[+-]$reset_color\s*$/$invert_color$1 $reset_escape\n/;
378+
my $add_color = $DiffHighlight::NEW_HIGHLIGHT[1];
379+
my $del_color = $DiffHighlight::OLD_HIGHLIGHT[1];
380+
381+
# This captures lines that do not have any ANSI in them (raw vanilla diff)
382+
if ($line eq "+\n") {
383+
$line = $invert_color . $add_color . " " . color('reset') . "\n";
384+
# This captures lines that do not have any ANSI in them (raw vanilla diff)
385+
} elsif ($line eq "-\n") {
386+
$line = $invert_color . $del_color . " " . color('reset') . "\n";
387+
# This handles everything else
388+
} else {
389+
$line =~ s/^($ansi_color_regex)[+-]$reset_color\s*$/$invert_color$1 $reset_escape\n/;
390+
}
380391

381392
return $line;
382393
}

0 commit comments

Comments
 (0)