get_line_cols_from_offset

Function get_line_cols_from_offset 

Source
pub fn get_line_cols_from_offset(
    file_path: &PathBuf,
    offset: usize,
) -> (usize, usize)
Expand description

Gets the line and column number from a given offset (of bytes) for given file_path.

This computes the line and column numbers from a buffer of bytes read from the file_path. In non-UTF-8 encoded files, this does not guarantee that a word boundary exists at the returned column number. However, the offset given to this function is expected to originate from diagnostic information provided by clang-format or clang-tidy.