Skip to content

Commit 7bd74e3

Browse files
Merge pull request #387 from ericbn/rename
Don't include ansi color codes in file1 and file2
2 parents 19e55f6 + eb4a5e7 commit 7bd74e3

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

diff-so-fancy

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ sub do_dsf_stuff {
318318
}
319319

320320
my $next = shift(@$input);
321-
my ($file1) = $next =~ /rename from (.+)/;
321+
my ($file1) = $next =~ /rename from (.+?)(\e|\t|$)/;
322322

323323
$next = shift(@$input);
324-
my ($file2) = $next =~ /rename to (.+)/;
324+
my ($file2) = $next =~ /rename to (.+?)(\e|\t|$)/;
325325

326326
if ($file1 && $file2) {
327327
# We may not have extracted this yet, so we pull from the config if not
@@ -625,14 +625,10 @@ sub file_change_string {
625625
# If the files aren't the same it's a rename
626626
} elsif ($file_1 ne $file_2) {
627627
my ($old, $new) = DiffHighlight::highlight_pair($file_1,$file_2,{only_diff => 1});
628+
# highlight_pair already includes reset_color, but adds newline characters that need to be trimmed off
628629
$old = trim($old);
629630
$new = trim($new);
630-
631-
# highlight_pair resets the colors, but we want it to be the meta color
632-
$old =~ s/(\e0?\[m)/$1$meta_color/g;
633-
$new =~ s/(\e0?\[m)/$1$meta_color/g;
634-
635-
return "renamed: $old to $new";
631+
return "renamed: $old$meta_color to $new"
636632
# Something we haven't thought of yet
637633
} else {
638634
return "$file_1 -> $file_2";

0 commit comments

Comments
 (0)