Skip to content

Commit 827765d

Browse files
Merge branch 'master' into next
2 parents 1a0ad54 + c3205c8 commit 827765d

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

diff-so-fancy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ my $ruler_width = git_config("diff-so-fancy.rulerWidth", undef);
2727
my $git_strip_prefix = git_config_boolean("diff.noprefix","false");
2828
my $has_stdin = has_stdin();
2929

30-
my $ansi_color_regex = qr/(\e\[([0-9]{1,3}(;[0-9]{1,3}){0,10})[mK])?/;
30+
my $ansi_regex = qr/\e\[([0-9]{1,3}(;[0-9]{1,3}){0,10})[mK]/;
31+
my $ansi_color_regex = qr/(${ansi_regex})?/;
3132
my $reset_color = color("reset");
3233
my $bold = color("bold");
3334
my $meta_color = "";
@@ -120,7 +121,7 @@ my $line_count = 0;
120121
while (my $line = <STDIN>) {
121122
# If the very first line of the diff doesn't start with ANSI color we're assuming
122123
# it's a raw patch file, and we have to color the added/removed lines ourself
123-
if (!$color_forced && $line_count == 0 && starts_with_ansi($line)) {
124+
if (!$color_forced && $line_count == 0 && !starts_with_ansi($line)) {
124125
$manually_color_lines = 1;
125126
}
126127

@@ -979,7 +980,8 @@ sub is_numeric {
979980
sub starts_with_ansi {
980981
my $str = shift();
981982

982-
if ($str =~ /^$ansi_color_regex/) {
983+
# NOTE: This is not `ansi_color_regex`, which includes "no ANSI sequences".
984+
if ($str =~ /^$ansi_regex/) {
983985
return 1;
984986
} else {
985987
return 0;

package-lock.json

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "diff-so-fancy",
3-
"version": "1.3.0",
3+
"version": "1.4.3",
44
"description": "Good-lookin' diffs with diff-highlight and more",
55
"bin": {
6-
"diff-so-fancy": "diff-so-fancy"
6+
"diff-so-fancy": "third_party/build_fatpack/diff-so-fancy"
77
},
88
"scripts": {
99
"test": "./test/bats/bin/bats test"

0 commit comments

Comments
 (0)