File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -219,18 +219,17 @@ impl FileObj {
219
219
}
220
220
}
221
221
222
- /// Gets the line and column number from a given `offset` (of bytes) for given
223
- /// `file_path `.
222
+ /// Gets the line number for a given `offset` (of bytes) from given the
223
+ /// byte array `contents `.
224
224
///
225
- /// This computes the line and column numbers from a buffer of bytes read from the
226
- /// `file_path`. In non-UTF-8 encoded files, this does not guarantee that a word
225
+ /// This computes the line number from a buffer of bytes.
226
+ /// In non-UTF-8 encoded files, this does not guarantee that a word
227
227
/// boundary exists at the returned column number. However, the `offset` given to this
228
228
/// function is expected to originate from diagnostic information provided by
229
- /// clang-format or clang-tidy .
229
+ /// clang-format.
230
230
pub fn get_line_count_from_offset ( contents : & [ u8 ] , offset : u32 ) -> u32 {
231
231
let offset = ( offset as usize ) . min ( contents. len ( ) ) ;
232
232
let lines = contents[ 0 ..offset] . split ( |byte| byte == & b'\n' ) ;
233
-
234
233
lines. count ( ) as u32
235
234
}
236
235
You can’t perform that action at this time.
0 commit comments