Skip to content

Commit 84aa638

Browse files
Merge pull request #414 from gramosg/master
Fix fg/bg extraction with l.t. 2 colors
2 parents 02c8c00 + 754f9df commit 84aa638

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

diff-so-fancy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,14 +918,15 @@ sub git_ansi_color {
918918

919919
if (grep { /bold/ } @parts) {
920920
push(@ansi_part, "1");
921-
@parts = grep { !/bold/ } @parts; # Remove from array
922921
}
923922

924923
if (grep { /reverse/ } @parts) {
925924
push(@ansi_part, "7");
926-
@parts = grep { !/reverse/ } @parts; # Remove from array
927925
}
928926

927+
# Remove parts that aren't colors
928+
@parts = grep { exists $colors->{$_} || is_numeric($_) } @parts;
929+
929930
my $fg = $parts[0] // "";
930931
my $bg = $parts[1] // "";
931932

test/git_ansi_color.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,15 @@ sub git_ansi_color {
121121

122122
if (grep { /bold/ } @parts) {
123123
push(@ansi_part, "1");
124-
@parts = grep { !/bold/ } @parts; # Remove from array
125124
}
126125

127126
if (grep { /reverse/ } @parts) {
128127
push(@ansi_part, "7");
129-
@parts = grep { !/reverse/ } @parts; # Remove from array
130128
}
131129

130+
# Remove parts that aren't colors
131+
@parts = grep { exists $colors->{$_} || is_numeric($_) } @parts;
132+
132133
my $fg = $parts[0] // "";
133134
my $bg = $parts[1] // "";
134135

0 commit comments

Comments
 (0)