File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -219,18 +219,17 @@ impl FileObj {
219219 }
220220}
221221
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 `.
224224///
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
227227/// boundary exists at the returned column number. However, the `offset` given to this
228228/// function is expected to originate from diagnostic information provided by
229- /// clang-format or clang-tidy .
229+ /// clang-format.
230230pub fn get_line_count_from_offset ( contents : & [ u8 ] , offset : u32 ) -> u32 {
231231 let offset = ( offset as usize ) . min ( contents. len ( ) ) ;
232232 let lines = contents[ 0 ..offset] . split ( |byte| byte == & b'\n' ) ;
233-
234233 lines. count ( ) as u32
235234}
236235
You can’t perform that action at this time.
0 commit comments