@@ -1462,7 +1462,7 @@ impl HumanEmitter {
1462
1462
max_line_num_len : usize ,
1463
1463
is_secondary : bool ,
1464
1464
is_cont : bool ,
1465
- ) -> io:: Result < ( ) > {
1465
+ ) -> io:: Result < CodeWindowStatus > {
1466
1466
let mut buffer = StyledBuffer :: new ( ) ;
1467
1467
1468
1468
if !msp. has_primary_spans ( ) && !msp. has_span_labels ( ) && is_secondary && !self . short_message
@@ -1575,12 +1575,14 @@ impl HumanEmitter {
1575
1575
}
1576
1576
let mut annotated_files = FileWithAnnotatedLines :: collect_annotations ( self , args, msp) ;
1577
1577
trace ! ( "{annotated_files:#?}" ) ;
1578
+ let mut code_window_status = CodeWindowStatus :: Open ;
1578
1579
1579
1580
// Make sure our primary file comes first
1580
1581
let primary_span = msp. primary_span ( ) . unwrap_or_default ( ) ;
1581
1582
let ( Some ( sm) , false ) = ( self . sm . as_ref ( ) , primary_span. is_dummy ( ) ) else {
1582
1583
// 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) ;
1584
1586
} ;
1585
1587
let primary_lo = sm. lookup_char_pos ( primary_span. lo ( ) ) ;
1586
1588
if let Ok ( pos) =
@@ -1639,6 +1641,13 @@ impl HumanEmitter {
1639
1641
}
1640
1642
line_idx += 1 ;
1641
1643
}
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
+ }
1642
1651
for ( label, is_primary) in labels. into_iter ( ) {
1643
1652
let style = if is_primary {
1644
1653
Style :: LabelPrimary
@@ -1976,7 +1985,7 @@ impl HumanEmitter {
1976
1985
// final step: take our styled buffer, render it, then output it
1977
1986
emit_to_destination ( & buffer. render ( ) , level, & mut self . dst , self . short_message ) ?;
1978
1987
1979
- Ok ( ( ) )
1988
+ Ok ( code_window_status )
1980
1989
}
1981
1990
1982
1991
fn column_width ( & self , code_offset : usize ) -> usize {
@@ -2491,7 +2500,7 @@ impl HumanEmitter {
2491
2500
!children. is_empty ( )
2492
2501
|| suggestions. iter ( ) . any ( |s| s. style != SuggestionStyle :: CompletelyHidden ) ,
2493
2502
) {
2494
- Ok ( ( ) ) => {
2503
+ Ok ( code_window_status ) => {
2495
2504
if !children. is_empty ( )
2496
2505
|| suggestions. iter ( ) . any ( |s| s. style != SuggestionStyle :: CompletelyHidden )
2497
2506
{
@@ -2502,7 +2511,7 @@ impl HumanEmitter {
2502
2511
{
2503
2512
// We'll continue the vertical bar to point into the next note.
2504
2513
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 ) {
2506
2515
// We'll close the vertical bar to visually end the code window.
2507
2516
self . draw_col_separator_end ( & mut buffer, 0 , max_line_num_len + 1 ) ;
2508
2517
}
@@ -3050,6 +3059,12 @@ enum DisplaySuggestion {
3050
3059
Add ,
3051
3060
}
3052
3061
3062
+ #[ derive( Clone , Copy , Debug ) ]
3063
+ enum CodeWindowStatus {
3064
+ Closed ,
3065
+ Open ,
3066
+ }
3067
+
3053
3068
impl FileWithAnnotatedLines {
3054
3069
/// Preprocess all the annotations so that they are grouped by file and by line number
3055
3070
/// This helps us quickly iterate over the whole message (including secondary file spans)
0 commit comments