@@ -58,6 +58,9 @@ struct Annotation {
5858 /// Is this annotation derived from primary span
5959 is_primary : bool ,
6060
61+ /// Is this a large span minimized down to a smaller span
62+ is_minimized : bool ,
63+
6164 /// Optional label to display adjacent to the annotation.
6265 label : Option < String > ,
6366}
@@ -90,6 +93,7 @@ pub enum Style {
9093 UnderlineSecondary ,
9194 LabelPrimary ,
9295 LabelSecondary ,
96+ OldSkoolNoteText ,
9397 OldSkoolNote ,
9498 NoStyle ,
9599}
@@ -383,10 +387,10 @@ impl FileInfo {
383387 // Basically, although this loses information, multi-line spans just
384388 // never look good.
385389
386- let ( line, start_col, mut end_col) = if lines. len ( ) == 1 {
387- ( lines[ 0 ] . line_index , lines[ 0 ] . start_col , lines[ 0 ] . end_col )
390+ let ( line, start_col, mut end_col, is_minimized ) = if lines. len ( ) == 1 {
391+ ( lines[ 0 ] . line_index , lines[ 0 ] . start_col , lines[ 0 ] . end_col , false )
388392 } else {
389- ( lines[ 0 ] . line_index , lines[ 0 ] . start_col , CharPos ( lines[ 0 ] . start_col . 0 + 1 ) )
393+ ( lines[ 0 ] . line_index , lines[ 0 ] . start_col , CharPos ( lines[ 0 ] . start_col . 0 + 1 ) , true )
390394 } ;
391395
392396 // Watch out for "empty spans". If we get a span like 6..6, we
@@ -402,6 +406,7 @@ impl FileInfo {
402406 self . lines [ index] . push_annotation ( start_col,
403407 end_col,
404408 is_primary,
409+ is_minimized,
405410 label) ;
406411 }
407412
@@ -498,6 +503,7 @@ impl FileInfo {
498503 match self . primary_span {
499504 Some ( span) => {
500505 let lo = codemap. lookup_char_pos ( span. lo ) ;
506+ let hi = codemap. lookup_char_pos ( span. hi ) ;
501507 //Before each secondary line in old skool-mode, print the label
502508 //as an old-style note
503509 if !line. annotations [ 0 ] . is_primary {
@@ -507,14 +513,15 @@ impl FileInfo {
507513 text: lo. file. name. clone( ) ,
508514 style: Style :: FileNameStyle ,
509515 } , StyledString {
510- text: format!( ":{}:{}: " , lo. line, lo. col. 0 + 1 ) ,
516+ text: format!( ":{}:{}: {}:{} " , lo. line, lo. col. 0 + 1 ,
517+ hi. line, hi. col. 0 +1 ) ,
511518 style: Style :: LineAndColumn ,
512519 } , StyledString {
513520 text: format!( "note: " ) ,
514- style: Style :: LabelSecondary ,
521+ style: Style :: OldSkoolNote ,
515522 } , StyledString {
516523 text: format!( "{}" , ann) ,
517- style: Style :: OldSkoolNote ,
524+ style: Style :: OldSkoolNoteText ,
518525 } ] ,
519526 kind : RenderedLineKind :: Annotations ,
520527 } ) ;
@@ -621,15 +628,15 @@ impl FileInfo {
621628 if annotation. is_primary {
622629 Style :: UnderlinePrimary
623630 } else {
624- Style :: UnderlineSecondary
631+ Style :: OldSkoolNote
625632 } ) ;
626633 }
627634 else {
628635 styled_buffer. putc ( 1 , p, '~' ,
629636 if annotation. is_primary {
630637 Style :: UnderlinePrimary
631638 } else {
632- Style :: UnderlineSecondary
639+ Style :: OldSkoolNote
633640 } ) ;
634641 }
635642 }
@@ -638,10 +645,14 @@ impl FileInfo {
638645 for p in annotation. start_col .. annotation. end_col {
639646 if annotation. is_primary {
640647 styled_buffer. putc ( 1 , p, '^' , Style :: UnderlinePrimary ) ;
641- styled_buffer. set_style ( 0 , p, Style :: UnderlinePrimary ) ;
648+ if !annotation. is_minimized {
649+ styled_buffer. set_style ( 0 , p, Style :: UnderlinePrimary ) ;
650+ }
642651 } else {
643652 styled_buffer. putc ( 1 , p, '-' , Style :: UnderlineSecondary ) ;
644- styled_buffer. set_style ( 0 , p, Style :: UnderlineSecondary ) ;
653+ if !annotation. is_minimized {
654+ styled_buffer. set_style ( 0 , p, Style :: UnderlineSecondary ) ;
655+ }
645656 }
646657 }
647658 }
@@ -842,11 +853,13 @@ impl Line {
842853 start : CharPos ,
843854 end : CharPos ,
844855 is_primary : bool ,
856+ is_minimized : bool ,
845857 label : Option < String > ) {
846858 self . annotations . push ( Annotation {
847859 start_col : start. 0 ,
848860 end_col : end. 0 ,
849861 is_primary : is_primary,
862+ is_minimized : is_minimized,
850863 label : label,
851864 } ) ;
852865 }
0 commit comments