@@ -1656,6 +1656,27 @@ impl HumanEmitter {
16561656 * style,
16571657 ) ;
16581658 }
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+ }
16591680 } else if line_idx_delta == 2 {
16601681 let unannotated_line = annotated_file
16611682 . file
@@ -1683,6 +1704,24 @@ impl HumanEmitter {
16831704 * style,
16841705 ) ;
16851706 }
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+ }
16861725 }
16871726 }
16881727
@@ -2435,7 +2474,16 @@ impl FileWithAnnotatedLines {
24352474 // the beginning doesn't have an underline, but the current logic seems to be
24362475 // working correctly.
24372476 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 {
24392487 // Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
24402488 add_annotation_to_file ( & mut output, file. clone ( ) , line, ann. as_line ( ) ) ;
24412489 }
0 commit comments