@@ -288,10 +288,14 @@ impl Renderer {
288288 }
289289 let mut message_iter = group. elements . iter ( ) . enumerate ( ) . peekable ( ) ;
290290 let mut last_was_suggestion = false ;
291+ let mut first_was_title = false ;
291292 while let Some ( ( i, section) ) = message_iter. next ( ) {
292293 let peek = message_iter. peek ( ) . map ( |( _, s) | s) . copied ( ) ;
293294 match & section {
294295 Element :: Title ( title) => {
296+ if i == 0 {
297+ first_was_title = true ;
298+ }
295299 let title_style = match ( i == 0 , g == 0 ) {
296300 ( true , true ) => TitleStyle :: MainHeader ,
297301 ( true , false ) => TitleStyle :: Header ,
@@ -329,11 +333,13 @@ impl Renderer {
329333 if let Some ( ( source_map, annotated_lines) ) =
330334 source_map_annotated_lines. pop_front ( )
331335 {
336+ let is_primary = primary_path == cause. path . as_ref ( )
337+ && i == first_was_title as usize ;
332338 self . render_snippet_annotations (
333339 & mut buffer,
334340 max_line_num_len,
335341 cause,
336- primary_path ,
342+ is_primary ,
337343 & source_map,
338344 & annotated_lines,
339345 max_depth,
@@ -722,7 +728,7 @@ impl Renderer {
722728 buffer : & mut StyledBuffer ,
723729 max_line_num_len : usize ,
724730 snippet : & Snippet < ' _ , Annotation < ' _ > > ,
725- primary_path : Option < & Cow < ' _ , str > > ,
731+ is_primary : bool ,
726732 sm : & SourceMap < ' _ > ,
727733 annotated_lines : & [ AnnotatedLineInfo < ' _ > ] ,
728734 multiline_depth : usize ,
@@ -732,7 +738,7 @@ impl Renderer {
732738 let mut origin = Origin :: path ( path. as_ref ( ) ) ;
733739 // print out the span location and spacer before we print the annotated source
734740 // 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);
736742
737743 if is_primary {
738744 origin. primary = true ;
@@ -776,11 +782,54 @@ impl Renderer {
776782 }
777783 let buffer_msg_line_offset = buffer. num_lines ( ) ;
778784 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+ ) ;
780824
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+ }
784833
785834 // Contains the vertical lines' positions for active multiline annotations
786835 let mut multilines = Vec :: new ( ) ;
0 commit comments