@@ -562,17 +562,37 @@ impl Renderer {
562
562
is_cont,
563
563
) ;
564
564
565
- if title. level . name != Some ( None ) {
565
+ let label_width = if title. level . name != Some ( None ) {
566
566
buffer. append (
567
567
buffer_msg_line_offset,
568
568
title. level . as_str ( ) ,
569
569
ElementStyle :: MainHeaderMsg ,
570
570
) ;
571
571
buffer. append ( buffer_msg_line_offset, ": " , ElementStyle :: NoStyle ) ;
572
- }
572
+ title. level . as_str ( ) . len ( ) + 2
573
+ } else {
574
+ 0
575
+ } ;
576
+ // The extra 3 ` ` is padding that's always needed to align to the
577
+ // label i.e. `note: `:
578
+ //
579
+ // error: message
580
+ // --> file.rs:13:20
581
+ // |
582
+ // 13 | <CODE>
583
+ // | ^^^^
584
+ // |
585
+ // = note: multiline
586
+ // message
587
+ // ++^^^------
588
+ // | | |
589
+ // | | |
590
+ // | | width of label
591
+ // | magic `3`
592
+ // `max_line_num_len`
593
+ let padding = max_line_num_len + 3 + label_width;
573
594
574
- let printed_lines =
575
- self . msgs_to_buffer ( buffer, title. title , max_line_num_len, "note" , None ) ;
595
+ let printed_lines = self . msgs_to_buffer ( buffer, title. title , padding, None ) ;
576
596
if is_cont && matches ! ( self . theme, OutputTheme :: Unicode ) {
577
597
// There's another note after this one, associated to the subwindow above.
578
598
// We write additional vertical lines to join them:
@@ -660,26 +680,9 @@ impl Renderer {
660
680
buffer : & mut StyledBuffer ,
661
681
title : & str ,
662
682
padding : usize ,
663
- label : & str ,
664
683
override_style : Option < ElementStyle > ,
665
684
) -> usize {
666
- // The extra 5 ` ` is padding that's always needed to align to the `note: `:
667
- //
668
- // error: message
669
- // --> file.rs:13:20
670
- // |
671
- // 13 | <CODE>
672
- // | ^^^^
673
- // |
674
- // = note: multiline
675
- // message
676
- // ++^^^----xx
677
- // | | | |
678
- // | | | magic `2`
679
- // | | length of label
680
- // | magic `3`
681
- // `max_line_num_len`
682
- let padding = " " . repeat ( padding + label. len ( ) + 5 ) ;
685
+ let padding = " " . repeat ( padding) ;
683
686
684
687
let mut line_number = buffer. num_lines ( ) . saturating_sub ( 1 ) ;
685
688
0 commit comments