File tree Expand file tree Collapse file tree 7 files changed +39
-32
lines changed Expand file tree Collapse file tree 7 files changed +39
-32
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,7 @@ impl Renderer {
534534 buffer,
535535 width_offset,
536536 code_offset,
537+ max_line_num_len,
537538 margin,
538539 ) ;
539540
@@ -606,6 +607,7 @@ impl Renderer {
606607 last_buffer_line_num,
607608 width_offset,
608609 code_offset,
610+ max_line_num_len,
609611 margin,
610612 ) ;
611613
@@ -647,6 +649,7 @@ impl Renderer {
647649 buffer : & mut StyledBuffer ,
648650 width_offset : usize ,
649651 code_offset : usize ,
652+ max_line_num_len : usize ,
650653 margin : Margin ,
651654 ) -> Vec < ( usize , ElementStyle ) > {
652655 // Draw:
@@ -685,6 +688,7 @@ impl Renderer {
685688 line_offset,
686689 width_offset,
687690 code_offset,
691+ max_line_num_len,
688692 margin,
689693 ) ;
690694
@@ -1186,6 +1190,7 @@ impl Renderer {
11861190 line_offset : usize ,
11871191 width_offset : usize ,
11881192 code_offset : usize ,
1193+ max_line_num_len : usize ,
11891194 margin : Margin ,
11901195 ) {
11911196 // Tabs are assumed to have been replaced by spaces in calling code.
@@ -1228,7 +1233,7 @@ impl Renderer {
12281233 buffer. puts (
12291234 line_offset,
12301235 0 ,
1231- & self . maybe_anonymized ( line_index) ,
1236+ & format ! ( "{:>max_line_num_len$}" , self . maybe_anonymized( line_index) ) ,
12321237 ElementStyle :: LineNumber ,
12331238 ) ;
12341239
Original file line number Diff line number Diff line change @@ -229,10 +229,12 @@ impl Level {
229229fn newline_count ( body : & str ) -> usize {
230230 #[ cfg( feature = "simd" ) ]
231231 {
232- memchr:: memchr_iter ( b'\n' , body. as_bytes ( ) ) . count ( )
232+ memchr:: memchr_iter ( b'\n' , body. as_bytes ( ) )
233+ . count ( )
234+ . saturating_sub ( 1 )
233235 }
234236 #[ cfg( not( feature = "simd" ) ) ]
235237 {
236- body. lines ( ) . count ( )
238+ body. lines ( ) . count ( ) . saturating_sub ( 1 )
237239 }
238240}
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ error:
149149 |
150150 ::: file2.rs
151151 |
152- 2 | This is slice 2
152+ 2 | This is slice 2
153153"# ] ] ;
154154 let renderer = Renderer :: plain ( ) ;
155155 assert_data_eq ! ( renderer. render( input) , expected) ;
Original file line number Diff line number Diff line change @@ -685,15 +685,15 @@ fn foo() {
685685error: foo
686686 --> test.rs:3:6
687687 |
688- 3 | X0 Y0 Z0
688+ 3 | X0 Y0 Z0
689689 | _______^
690- 4 | | X1 Y1 Z1
690+ 4 | | X1 Y1 Z1
691691 | | ____^____-
692692 | ||____|
693693 | | `X` is a good letter
694- 5 | | 1
695- 6 | | 2
696- 7 | | 3
694+ 5 | | 1
695+ 6 | | 2
696+ 7 | | 3
697697... |
69869815 | | X2 Y2 Z2
69969916 | | X3 Y3 Z3
@@ -739,15 +739,15 @@ fn foo() {
739739error: foo
740740 --> test.rs:3:6
741741 |
742- 3 | X0 Y0 Z0
742+ 3 | X0 Y0 Z0
743743 | _______^
744- 4 | | 1
745- 5 | | 2
746- 6 | | 3
747- 7 | | X1 Y1 Z1
744+ 4 | | 1
745+ 5 | | 2
746+ 6 | | 3
747+ 7 | | X1 Y1 Z1
748748 | | _________-
749- 8 | || 4
750- 9 | || 5
749+ 8 | || 4
750+ 9 | || 5
75175110 | || 6
75275211 | || X2 Y2 Z2
753753 | ||__________- `Z` is a good letter too
You can’t perform that action at this time.
0 commit comments