@@ -58,6 +58,9 @@ struct Annotation {
58
58
/// Is this annotation derived from primary span
59
59
is_primary : bool ,
60
60
61
+ /// Is this a large span minimized down to a smaller span
62
+ is_minimized : bool ,
63
+
61
64
/// Optional label to display adjacent to the annotation.
62
65
label : Option < String > ,
63
66
}
@@ -90,6 +93,7 @@ pub enum Style {
90
93
UnderlineSecondary ,
91
94
LabelPrimary ,
92
95
LabelSecondary ,
96
+ OldSkoolNoteText ,
93
97
OldSkoolNote ,
94
98
NoStyle ,
95
99
}
@@ -383,10 +387,10 @@ impl FileInfo {
383
387
// Basically, although this loses information, multi-line spans just
384
388
// never look good.
385
389
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 )
388
392
} 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 )
390
394
} ;
391
395
392
396
// Watch out for "empty spans". If we get a span like 6..6, we
@@ -402,6 +406,7 @@ impl FileInfo {
402
406
self . lines [ index] . push_annotation ( start_col,
403
407
end_col,
404
408
is_primary,
409
+ is_minimized,
405
410
label) ;
406
411
}
407
412
@@ -498,6 +503,7 @@ impl FileInfo {
498
503
match self . primary_span {
499
504
Some ( span) => {
500
505
let lo = codemap. lookup_char_pos ( span. lo ) ;
506
+ let hi = codemap. lookup_char_pos ( span. hi ) ;
501
507
//Before each secondary line in old skool-mode, print the label
502
508
//as an old-style note
503
509
if !line. annotations [ 0 ] . is_primary {
@@ -507,14 +513,15 @@ impl FileInfo {
507
513
text: lo. file. name. clone( ) ,
508
514
style: Style :: FileNameStyle ,
509
515
} , 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 ) ,
511
518
style: Style :: LineAndColumn ,
512
519
} , StyledString {
513
520
text: format!( "note: " ) ,
514
- style: Style :: LabelSecondary ,
521
+ style: Style :: OldSkoolNote ,
515
522
} , StyledString {
516
523
text: format!( "{}" , ann) ,
517
- style: Style :: OldSkoolNote ,
524
+ style: Style :: OldSkoolNoteText ,
518
525
} ] ,
519
526
kind : RenderedLineKind :: Annotations ,
520
527
} ) ;
@@ -621,15 +628,15 @@ impl FileInfo {
621
628
if annotation. is_primary {
622
629
Style :: UnderlinePrimary
623
630
} else {
624
- Style :: UnderlineSecondary
631
+ Style :: OldSkoolNote
625
632
} ) ;
626
633
}
627
634
else {
628
635
styled_buffer. putc ( 1 , p, '~' ,
629
636
if annotation. is_primary {
630
637
Style :: UnderlinePrimary
631
638
} else {
632
- Style :: UnderlineSecondary
639
+ Style :: OldSkoolNote
633
640
} ) ;
634
641
}
635
642
}
@@ -638,10 +645,14 @@ impl FileInfo {
638
645
for p in annotation. start_col .. annotation. end_col {
639
646
if annotation. is_primary {
640
647
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
+ }
642
651
} else {
643
652
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
+ }
645
656
}
646
657
}
647
658
}
@@ -842,11 +853,13 @@ impl Line {
842
853
start : CharPos ,
843
854
end : CharPos ,
844
855
is_primary : bool ,
856
+ is_minimized : bool ,
845
857
label : Option < String > ) {
846
858
self . annotations . push ( Annotation {
847
859
start_col : start. 0 ,
848
860
end_col : end. 0 ,
849
861
is_primary : is_primary,
862
+ is_minimized : is_minimized,
850
863
label : label,
851
864
} ) ;
852
865
}
0 commit comments