@@ -288,10 +288,14 @@ impl Renderer {
288
288
}
289
289
let mut message_iter = group. elements . iter ( ) . enumerate ( ) . peekable ( ) ;
290
290
let mut last_was_suggestion = false ;
291
+ let mut first_was_title = false ;
291
292
while let Some ( ( i, section) ) = message_iter. next ( ) {
292
293
let peek = message_iter. peek ( ) . map ( |( _, s) | s) . copied ( ) ;
293
294
match & section {
294
295
Element :: Title ( title) => {
296
+ if i == 0 {
297
+ first_was_title = true ;
298
+ }
295
299
let title_style = match ( i == 0 , g == 0 ) {
296
300
( true , true ) => TitleStyle :: MainHeader ,
297
301
( true , false ) => TitleStyle :: Header ,
@@ -329,11 +333,13 @@ impl Renderer {
329
333
if let Some ( ( source_map, annotated_lines) ) =
330
334
source_map_annotated_lines. pop_front ( )
331
335
{
336
+ let is_primary = primary_path == cause. path . as_ref ( )
337
+ && i == first_was_title as usize ;
332
338
self . render_snippet_annotations (
333
339
& mut buffer,
334
340
max_line_num_len,
335
341
cause,
336
- primary_path ,
342
+ is_primary ,
337
343
& source_map,
338
344
& annotated_lines,
339
345
max_depth,
@@ -722,7 +728,7 @@ impl Renderer {
722
728
buffer : & mut StyledBuffer ,
723
729
max_line_num_len : usize ,
724
730
snippet : & Snippet < ' _ , Annotation < ' _ > > ,
725
- primary_path : Option < & Cow < ' _ , str > > ,
731
+ is_primary : bool ,
726
732
sm : & SourceMap < ' _ > ,
727
733
annotated_lines : & [ AnnotatedLineInfo < ' _ > ] ,
728
734
multiline_depth : usize ,
@@ -732,7 +738,7 @@ impl Renderer {
732
738
let mut origin = Origin :: path ( path. as_ref ( ) ) ;
733
739
// print out the span location and spacer before we print the annotated source
734
740
// to do this, we need to know if this span will be primary
735
- let is_primary = primary_path == Some ( & origin. path ) ;
741
+ // let is_primary = primary_path == Some(&origin.path);
736
742
737
743
if is_primary {
738
744
origin. primary = true ;
@@ -776,11 +782,54 @@ impl Renderer {
776
782
}
777
783
let buffer_msg_line_offset = buffer. num_lines ( ) ;
778
784
self . render_origin ( buffer, max_line_num_len, & origin, buffer_msg_line_offset) ;
779
- }
785
+ // Put in the spacer between the location and annotated source
786
+ self . draw_col_separator_no_space (
787
+ buffer,
788
+ buffer_msg_line_offset + 1 ,
789
+ max_line_num_len + 1 ,
790
+ ) ;
791
+ } else {
792
+ let buffer_msg_line_offset = buffer. num_lines ( ) ;
793
+ if is_primary {
794
+ if self . theme == OutputTheme :: Unicode {
795
+ buffer. puts (
796
+ buffer_msg_line_offset,
797
+ max_line_num_len,
798
+ self . file_start ( ) ,
799
+ ElementStyle :: LineNumber ,
800
+ ) ;
801
+ } else {
802
+ self . draw_col_separator_no_space (
803
+ buffer,
804
+ buffer_msg_line_offset,
805
+ max_line_num_len + 1 ,
806
+ ) ;
807
+ }
808
+ } else {
809
+ // Add spacing line, as shown:
810
+ // --> $DIR/file:54:15
811
+ // |
812
+ // LL | code
813
+ // | ^^^^
814
+ // | (<- It prints *this* line)
815
+ // ::: $DIR/other_file.rs:15:5
816
+ // |
817
+ // LL | code
818
+ // | ----
819
+ self . draw_col_separator_no_space (
820
+ buffer,
821
+ buffer_msg_line_offset,
822
+ max_line_num_len + 1 ,
823
+ ) ;
780
824
781
- // Put in the spacer between the location and annotated source
782
- let buffer_msg_line_offset = buffer. num_lines ( ) ;
783
- self . draw_col_separator_no_space ( buffer, buffer_msg_line_offset, max_line_num_len + 1 ) ;
825
+ buffer. puts (
826
+ buffer_msg_line_offset + 1 ,
827
+ max_line_num_len,
828
+ self . secondary_file_start ( ) ,
829
+ ElementStyle :: LineNumber ,
830
+ ) ;
831
+ }
832
+ }
784
833
785
834
// Contains the vertical lines' positions for active multiline annotations
786
835
let mut multilines = Vec :: new ( ) ;
0 commit comments