@@ -1656,6 +1656,27 @@ impl HumanEmitter {
1656
1656
* style,
1657
1657
) ;
1658
1658
}
1659
+ if let Some ( line) = annotated_file. lines . get ( line_idx) {
1660
+ for ann in & line. annotations {
1661
+ if let AnnotationType :: MultilineStart ( pos) = ann. annotation_type
1662
+ {
1663
+ // In the case where we have elided the entire start of the
1664
+ // multispan because those lines were empty, we still need
1665
+ // to draw the `|`s across the `...`.
1666
+ draw_multiline_line (
1667
+ & mut buffer,
1668
+ last_buffer_line_num,
1669
+ width_offset,
1670
+ pos,
1671
+ if ann. is_primary {
1672
+ Style :: UnderlinePrimary
1673
+ } else {
1674
+ Style :: UnderlineSecondary
1675
+ } ,
1676
+ ) ;
1677
+ }
1678
+ }
1679
+ }
1659
1680
} else if line_idx_delta == 2 {
1660
1681
let unannotated_line = annotated_file
1661
1682
. file
@@ -1683,6 +1704,24 @@ impl HumanEmitter {
1683
1704
* style,
1684
1705
) ;
1685
1706
}
1707
+ if let Some ( line) = annotated_file. lines . get ( line_idx) {
1708
+ for ann in & line. annotations {
1709
+ if let AnnotationType :: MultilineStart ( pos) = ann. annotation_type
1710
+ {
1711
+ draw_multiline_line (
1712
+ & mut buffer,
1713
+ last_buffer_line_num,
1714
+ width_offset,
1715
+ pos,
1716
+ if ann. is_primary {
1717
+ Style :: UnderlinePrimary
1718
+ } else {
1719
+ Style :: UnderlineSecondary
1720
+ } ,
1721
+ ) ;
1722
+ }
1723
+ }
1724
+ }
1686
1725
}
1687
1726
}
1688
1727
@@ -2435,7 +2474,16 @@ impl FileWithAnnotatedLines {
2435
2474
// the beginning doesn't have an underline, but the current logic seems to be
2436
2475
// working correctly.
2437
2476
let middle = min ( ann. line_start + 4 , ann. line_end ) ;
2438
- for line in ann. line_start + 1 ..middle {
2477
+ // We'll show up to 4 lines past the beginning of the multispan start.
2478
+ // We will *not* include the tail of lines that are only whitespace.
2479
+ let until = ( ann. line_start ..middle)
2480
+ . rev ( )
2481
+ . filter_map ( |line| file. get_line ( line - 1 ) . map ( |s| ( line + 1 , s) ) )
2482
+ . filter ( |( _, s) | !s. trim ( ) . is_empty ( ) )
2483
+ . map ( |( line, _) | line)
2484
+ . next ( )
2485
+ . unwrap_or ( ann. line_start ) ;
2486
+ for line in ann. line_start + 1 ..until {
2439
2487
// Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
2440
2488
add_annotation_to_file ( & mut output, file. clone ( ) , line, ann. as_line ( ) ) ;
2441
2489
}
0 commit comments