@@ -1638,6 +1638,27 @@ impl HumanEmitter {
16381638 * style,
16391639 ) ;
16401640 }
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+ }
16411662 } else if line_idx_delta == 2 {
16421663 let unannotated_line = annotated_file
16431664 . file
@@ -1665,6 +1686,24 @@ impl HumanEmitter {
16651686 * style,
16661687 ) ;
16671688 }
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+ }
16681707 }
16691708 }
16701709
@@ -2417,7 +2456,15 @@ impl FileWithAnnotatedLines {
24172456 // the beginning doesn't have an underline, but the current logic seems to be
24182457 // working correctly.
24192458 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 {
24212468 // Every `|` that joins the beginning of the span (`___^`) to the end (`|__^`).
24222469 add_annotation_to_file ( & mut output, file. clone ( ) , line, ann. as_line ( ) ) ;
24232470 }
0 commit comments