@@ -1462,7 +1462,7 @@ impl HumanEmitter {
14621462 max_line_num_len : usize ,
14631463 is_secondary : bool ,
14641464 is_cont : bool ,
1465- ) -> io:: Result < ( ) > {
1465+ ) -> io:: Result < CodeWindowStatus > {
14661466 let mut buffer = StyledBuffer :: new ( ) ;
14671467
14681468 if !msp. has_primary_spans ( ) && !msp. has_span_labels ( ) && is_secondary && !self . short_message
@@ -1575,12 +1575,14 @@ impl HumanEmitter {
15751575 }
15761576 let mut annotated_files = FileWithAnnotatedLines :: collect_annotations ( self , args, msp) ;
15771577 trace ! ( "{annotated_files:#?}" ) ;
1578+ let mut code_window_status = CodeWindowStatus :: Open ;
15781579
15791580 // Make sure our primary file comes first
15801581 let primary_span = msp. primary_span ( ) . unwrap_or_default ( ) ;
15811582 let ( Some ( sm) , false ) = ( self . sm . as_ref ( ) , primary_span. is_dummy ( ) ) else {
15821583 // If we don't have span information, emit and exit
1583- return emit_to_destination ( & buffer. render ( ) , level, & mut self . dst , self . short_message ) ;
1584+ return emit_to_destination ( & buffer. render ( ) , level, & mut self . dst , self . short_message )
1585+ . map ( |_| code_window_status) ;
15841586 } ;
15851587 let primary_lo = sm. lookup_char_pos ( primary_span. lo ( ) ) ;
15861588 if let Ok ( pos) =
@@ -1639,6 +1641,13 @@ impl HumanEmitter {
16391641 }
16401642 line_idx += 1 ;
16411643 }
1644+ if is_cont
1645+ && file_idx == annotated_files_len - 1
1646+ && annotation_id == annotated_file. lines . len ( ) - 1
1647+ && !labels. is_empty ( )
1648+ {
1649+ code_window_status = CodeWindowStatus :: Closed ;
1650+ }
16421651 for ( label, is_primary) in labels. into_iter ( ) {
16431652 let style = if is_primary {
16441653 Style :: LabelPrimary
@@ -1976,7 +1985,7 @@ impl HumanEmitter {
19761985 // final step: take our styled buffer, render it, then output it
19771986 emit_to_destination ( & buffer. render ( ) , level, & mut self . dst , self . short_message ) ?;
19781987
1979- Ok ( ( ) )
1988+ Ok ( code_window_status )
19801989 }
19811990
19821991 fn column_width ( & self , code_offset : usize ) -> usize {
@@ -2491,7 +2500,7 @@ impl HumanEmitter {
24912500 !children. is_empty ( )
24922501 || suggestions. iter ( ) . any ( |s| s. style != SuggestionStyle :: CompletelyHidden ) ,
24932502 ) {
2494- Ok ( ( ) ) => {
2503+ Ok ( code_window_status ) => {
24952504 if !children. is_empty ( )
24962505 || suggestions. iter ( ) . any ( |s| s. style != SuggestionStyle :: CompletelyHidden )
24972506 {
@@ -2502,7 +2511,7 @@ impl HumanEmitter {
25022511 {
25032512 // We'll continue the vertical bar to point into the next note.
25042513 self . draw_col_separator_no_space ( & mut buffer, 0 , max_line_num_len + 1 ) ;
2505- } else {
2514+ } else if matches ! ( code_window_status , CodeWindowStatus :: Open ) {
25062515 // We'll close the vertical bar to visually end the code window.
25072516 self . draw_col_separator_end ( & mut buffer, 0 , max_line_num_len + 1 ) ;
25082517 }
@@ -3050,6 +3059,12 @@ enum DisplaySuggestion {
30503059 Add ,
30513060}
30523061
3062+ #[ derive( Clone , Copy , Debug ) ]
3063+ enum CodeWindowStatus {
3064+ Closed ,
3065+ Open ,
3066+ }
3067+
30533068impl FileWithAnnotatedLines {
30543069 /// Preprocess all the annotations so that they are grouped by file and by line number
30553070 /// This helps us quickly iterate over the whole message (including secondary file spans)
0 commit comments