@@ -37,6 +37,7 @@ fn format_missing_line_num(
37
37
prev_num : LineNumber ,
38
38
source_dims : & SourceDimensions ,
39
39
is_lhs : bool ,
40
+ use_color : bool ,
40
41
) -> String {
41
42
let column_width = if is_lhs {
42
43
source_dims. lhs_line_nums_width
@@ -54,13 +55,18 @@ fn format_missing_line_num(
54
55
return "" . into ( ) ;
55
56
}
56
57
58
+ let mut style = Style :: new ( ) ;
59
+ if use_color {
60
+ style = style. dimmed ( ) ;
61
+ }
62
+
57
63
let num_digits = format ! ( "{}" , prev_num. one_indexed( ) ) . len ( ) ;
58
64
format ! (
59
65
"{:>width$} " ,
60
66
( if after_end { " " } else { "." } ) . repeat( num_digits) ,
61
67
width = column_width - 1
62
68
)
63
- . dimmed ( )
69
+ . style ( style )
64
70
. to_string ( )
65
71
}
66
72
@@ -133,6 +139,7 @@ fn display_line_nums(
133
139
prev_lhs_line_num. unwrap_or_else ( || 1 . into ( ) ) ,
134
140
source_dims,
135
141
true ,
142
+ use_color,
136
143
) ,
137
144
} ;
138
145
let display_rhs_line_num: String = match rhs_line_num {
@@ -152,6 +159,7 @@ fn display_line_nums(
152
159
prev_rhs_line_num. unwrap_or_else ( || 1 . into ( ) ) ,
153
160
source_dims,
154
161
false ,
162
+ use_color,
155
163
) ,
156
164
} ;
157
165
@@ -469,6 +477,7 @@ pub fn print(
469
477
. unwrap_or_else ( || prev_lhs_line_num. unwrap_or_else ( || 10 . into ( ) ) ) ,
470
478
& source_dims,
471
479
true ,
480
+ use_color,
472
481
) ;
473
482
if let Some ( line_num) = lhs_line_num {
474
483
if lhs_lines_with_novel. contains ( & line_num) {
@@ -489,6 +498,7 @@ pub fn print(
489
498
. unwrap_or_else ( || prev_rhs_line_num. unwrap_or_else ( || 10 . into ( ) ) ) ,
490
499
& source_dims,
491
500
false ,
501
+ use_color,
492
502
) ;
493
503
if let Some ( line_num) = rhs_line_num {
494
504
if rhs_lines_with_novel. contains ( & line_num) {
@@ -551,9 +561,13 @@ mod tests {
551
561
) ;
552
562
553
563
assert_eq ! (
554
- format_missing_line_num( 0 . into( ) , & source_dims, true ) ,
564
+ format_missing_line_num( 0 . into( ) , & source_dims, true , true ) ,
555
565
". " . dimmed( ) . to_string( )
556
566
) ;
567
+ assert_eq ! (
568
+ format_missing_line_num( 0 . into( ) , & source_dims, true , false ) ,
569
+ ". " . to_string( )
570
+ ) ;
557
571
}
558
572
559
573
#[ test]
@@ -569,9 +583,13 @@ mod tests {
569
583
) ;
570
584
571
585
assert_eq ! (
572
- format_missing_line_num( 1 . into( ) , & source_dims, true ) ,
586
+ format_missing_line_num( 1 . into( ) , & source_dims, true , true ) ,
573
587
" " . dimmed( ) . to_string( )
574
588
) ;
589
+ assert_eq ! (
590
+ format_missing_line_num( 1 . into( ) , & source_dims, true , false ) ,
591
+ " " . to_string( )
592
+ ) ;
575
593
}
576
594
577
595
#[ test]
0 commit comments