@@ -111,10 +111,9 @@ fn format_slice(
111
111
) -> Vec < DisplayLine < ' _ > > {
112
112
let main_range = slice. annotations . get ( 0 ) . map ( |x| x. range . 0 ) ;
113
113
let origin = slice. origin ;
114
- let line_start = slice. line_start ;
115
114
let need_empty_header = origin. is_some ( ) || is_first;
116
115
let mut body = format_body ( slice, need_empty_header, has_footer, margin) ;
117
- let header = format_header ( origin, main_range, line_start , & body, is_first) ;
116
+ let header = format_header ( origin, main_range, & body, is_first) ;
118
117
let mut result = vec ! [ ] ;
119
118
120
119
if let Some ( header) = header {
@@ -133,7 +132,6 @@ fn zip_opt<A, B>(a: Option<A>, b: Option<B>) -> Option<(A, B)> {
133
132
fn format_header < ' a > (
134
133
origin : Option < & ' a str > ,
135
134
main_range : Option < usize > ,
136
- mut row : usize ,
137
135
body : & [ DisplayLine < ' _ > ] ,
138
136
is_first : bool ,
139
137
) -> Option < DisplayLine < ' a > > {
@@ -145,24 +143,26 @@ fn format_header<'a>(
145
143
146
144
if let Some ( ( main_range, path) ) = zip_opt ( main_range, origin) {
147
145
let mut col = 1 ;
146
+ let mut line_offset = 1 ;
148
147
149
148
for item in body {
150
149
if let DisplayLine :: Source {
151
150
line : DisplaySourceLine :: Content { range, .. } ,
151
+ lineno,
152
152
..
153
153
} = item
154
154
{
155
155
if main_range >= range. 0 && main_range <= range. 1 {
156
156
col = main_range - range. 0 + 1 ;
157
+ line_offset = lineno. unwrap_or ( 1 ) ;
157
158
break ;
158
159
}
159
- row += 1 ;
160
160
}
161
161
}
162
162
163
163
return Some ( DisplayLine :: Raw ( DisplayRawLine :: Origin {
164
164
path,
165
- pos : Some ( ( row , col) ) ,
165
+ pos : Some ( ( line_offset , col) ) ,
166
166
header_type : display_header,
167
167
} ) ) ;
168
168
}
@@ -307,7 +307,7 @@ fn format_body(
307
307
let char_widths = line
308
308
. chars ( )
309
309
. map ( |c| unicode_width:: UnicodeWidthChar :: width ( c) . unwrap_or ( 0 ) )
310
- . chain ( std:: iter:: once ( 1 ) ) // treat the end of line as signle -width
310
+ . chain ( std:: iter:: once ( 1 ) ) // treat the end of line as single -width
311
311
. collect :: < Vec < _ > > ( ) ;
312
312
body. push ( DisplayLine :: Source {
313
313
lineno : Some ( current_line) ,
0 commit comments