File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -974,6 +974,7 @@ sub set_ansi_color {
974
974
}
975
975
}
976
976
977
+ # Is the string 100% numeric
977
978
sub is_numeric {
978
979
my $s = shift ();
979
980
@@ -984,6 +985,7 @@ sub is_numeric {
984
985
return 0;
985
986
}
986
987
988
+ # Does the string start with ANSI
987
989
sub starts_with_ansi {
988
990
my $str = shift ();
989
991
@@ -1054,6 +1056,7 @@ sub show_debug_info {
1054
1056
print " Operating System: $^O\n " ;
1055
1057
}
1056
1058
1059
+ # Boolean to yes/no string
1057
1060
sub yes_no {
1058
1061
my $val = shift ();
1059
1062
@@ -1073,6 +1076,7 @@ sub init_diff_highlight_colors {
1073
1076
$DiffHighlight::OLD_HIGHLIGHT [1] = git_ansi_color(git_config(' color.diff-highlight.oldhighlight' )) || $DiffHighlight::OLD_HIGHLIGHT [1];
1074
1077
}
1075
1078
1079
+ # Write a line to the debug log which is opened on the fly as-needed
1076
1080
sub debug_log {
1077
1081
my $log_line = shift ();
1078
1082
my $file = " /tmp/diff-so-fancy.debug.log" ;
@@ -1088,12 +1092,16 @@ sub debug_log {
1088
1092
return 1;
1089
1093
}
1090
1094
1095
+ # Count the number of context lines in the diff
1091
1096
sub calculate_context_lines {
1092
1097
my @lines = @_ ;
1093
1098
my $count = 0;
1094
1099
my $hunk_line = 0;
1095
1100
1101
+ # Count the number of lines between the hunk line and the
1102
+ # first + or - line
1096
1103
foreach my $line (@lines ) {
1104
+ # Look for the hunk line before we start
1097
1105
if ($line =~ / ^${ansi_color_regex} (@@@* .+? @@@*)(.*)/ ) {
1098
1106
$hunk_line = $count ;
1099
1107
} elsif ($hunk_line && $line =~ / ^${ansi_color_regex} [+-]/ ) {
You can’t perform that action at this time.
0 commit comments