@@ -111,10 +111,9 @@ fn format_slice(
111111) -> Vec < DisplayLine < ' _ > > {
112112 let main_range = slice. annotations . get ( 0 ) . map ( |x| x. range . 0 ) ;
113113 let origin = slice. origin ;
114- let line_start = slice. line_start ;
115114 let need_empty_header = origin. is_some ( ) || is_first;
116115 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) ;
118117 let mut result = vec ! [ ] ;
119118
120119 if let Some ( header) = header {
@@ -133,7 +132,6 @@ fn zip_opt<A, B>(a: Option<A>, b: Option<B>) -> Option<(A, B)> {
133132fn format_header < ' a > (
134133 origin : Option < & ' a str > ,
135134 main_range : Option < usize > ,
136- mut row : usize ,
137135 body : & [ DisplayLine < ' _ > ] ,
138136 is_first : bool ,
139137) -> Option < DisplayLine < ' a > > {
@@ -145,24 +143,26 @@ fn format_header<'a>(
145143
146144 if let Some ( ( main_range, path) ) = zip_opt ( main_range, origin) {
147145 let mut col = 1 ;
146+ let mut line_offset = 1 ;
148147
149148 for item in body {
150149 if let DisplayLine :: Source {
151150 line : DisplaySourceLine :: Content { range, .. } ,
151+ lineno,
152152 ..
153153 } = item
154154 {
155155 if main_range >= range. 0 && main_range <= range. 1 {
156156 col = main_range - range. 0 + 1 ;
157+ line_offset = lineno. unwrap_or ( 1 ) ;
157158 break ;
158159 }
159- row += 1 ;
160160 }
161161 }
162162
163163 return Some ( DisplayLine :: Raw ( DisplayRawLine :: Origin {
164164 path,
165- pos : Some ( ( row , col) ) ,
165+ pos : Some ( ( line_offset , col) ) ,
166166 header_type : display_header,
167167 } ) ) ;
168168 }
@@ -307,7 +307,7 @@ fn format_body(
307307 let char_widths = line
308308 . chars ( )
309309 . 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
311311 . collect :: < Vec < _ > > ( ) ;
312312 body. push ( DisplayLine :: Source {
313313 lineno : Some ( current_line) ,
0 commit comments