@@ -1638,6 +1638,27 @@ impl HumanEmitter {
1638
1638
* style,
1639
1639
) ;
1640
1640
}
1641
+ if let Some ( line) = annotated_file. lines . get ( line_idx) {
1642
+ for ann in & line. annotations {
1643
+ if let AnnotationType :: MultilineStart ( pos) = ann. annotation_type
1644
+ {
1645
+ // In the case where we have elided the entire start of the
1646
+ // multispan because those lines were empty, we still need
1647
+ // to draw the `|`s across the `...`.
1648
+ draw_multiline_line (
1649
+ & mut buffer,
1650
+ last_buffer_line_num,
1651
+ width_offset,
1652
+ pos,
1653
+ if ann. is_primary {
1654
+ Style :: UnderlinePrimary
1655
+ } else {
1656
+ Style :: UnderlineSecondary
1657
+ } ,
1658
+ ) ;
1659
+ }
1660
+ }
1661
+ }
1641
1662
} else if line_idx_delta == 2 {
1642
1663
let unannotated_line = annotated_file
1643
1664
. file
@@ -1665,6 +1686,24 @@ impl HumanEmitter {
1665
1686
* style,
1666
1687
) ;
1667
1688
}
1689
+ if let Some ( line) = annotated_file. lines . get ( line_idx) {
1690
+ for ann in & line. annotations {
1691
+ if let AnnotationType :: MultilineStart ( pos) = ann. annotation_type
1692
+ {
1693
+ draw_multiline_line (
1694
+ & mut buffer,
1695
+ last_buffer_line_num,
1696
+ width_offset,
1697
+ pos,
1698
+ if ann. is_primary {
1699
+ Style :: UnderlinePrimary
1700
+ } else {
1701
+ Style :: UnderlineSecondary
1702
+ } ,
1703
+ ) ;
1704
+ }
1705
+ }
1706
+ }
1668
1707
}
1669
1708
}
1670
1709
@@ -2417,7 +2456,15 @@ impl FileWithAnnotatedLines {
2417
2456
// the beginning doesn't have an underline, but the current logic seems to be
2418
2457
// working correctly.
2419
2458
let middle = min ( ann. line_start + 4 , ann. line_end ) ;
2420
- for line in ann. line_start + 1 ..middle {
2459
+ // We'll show up to 4 lines past the beginning of the multispan start.
2460
+ // We will *not* include the tail of lines that are only whitespace.
2461
+ let until = ( ann. line_start ..middle)
2462
+ . rev ( )
2463
+ . filter_map ( |line| file. get_line ( line - 1 ) . map ( |s| ( line + 1 , s) ) )
2464
+ . find ( |( _, s) | !s. trim ( ) . is_empty ( ) )
2465
+ . map ( |( line, _) | line)
2466
+ . unwrap_or ( ann. line_start ) ;
2467
+ for line in ann. line_start + 1 ..until {
2421
2468
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
2422
2469
add_annotation_to_file ( & mut output, file. clone ( ) , line, ann. as_line ( ) ) ;
2423
2470
}
0 commit comments