File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -1057,6 +1057,7 @@ fn format_body(
10571057 Range { start, .. } if start > line_end_index => true ,
10581058 Range { start, end }
10591059 if start >= line_start_index && end <= line_end_index
1060+ // Allow annotating eof or stripped eol
10601061 || start == line_end_index && end - start <= 1 =>
10611062 {
10621063 if let DisplayLine :: Source {
@@ -1068,14 +1069,15 @@ fn format_body(
10681069 . chars ( )
10691070 . map ( |c| unicode_width:: UnicodeWidthChar :: width ( c) . unwrap_or ( 0 ) )
10701071 . sum :: < usize > ( ) ;
1071- // This allows for annotations to be placed one past the
1072- // last character
1073- let safe_end = ( end - line_start_index) . saturating_sub ( line_length) ;
1074- let annotation_end_col = line[ 0 ..( end - line_start_index) - safe_end]
1072+ let mut annotation_end_col = line
1073+ [ 0 ..( end - line_start_index) . min ( line_length) ]
10751074 . chars ( )
10761075 . map ( |c| unicode_width:: UnicodeWidthChar :: width ( c) . unwrap_or ( 0 ) )
1077- . sum :: < usize > ( )
1078- + safe_end;
1076+ . sum :: < usize > ( ) ;
1077+ if annotation_start_col == annotation_end_col {
1078+ // At least highlight something
1079+ annotation_end_col += 1 ;
1080+ }
10791081
10801082 span_left_margin = min ( span_left_margin, annotation_start_col) ;
10811083 span_right_margin = max ( span_right_margin, annotation_end_col) ;
You can’t perform that action at this time.
0 commit comments