This commit is contained in:
Ariel Davis 2023-05-06 01:37:25 -07:00
parent 0ad2450396
commit 6500487735

View file

@ -148,8 +148,8 @@ impl LineIndex {
/// e.g. if it points to the middle of a multi-byte character. /// e.g. if it points to the middle of a multi-byte character.
pub fn try_line_col(&self, offset: TextSize) -> Option<LineCol> { pub fn try_line_col(&self, offset: TextSize) -> Option<LineCol> {
let line = self.newlines.partition_point(|&it| it <= offset).checked_sub(1)?; let line = self.newlines.partition_point(|&it| it <= offset).checked_sub(1)?;
let line_start_offset = self.newlines.get(line)?; let start = self.newlines.get(line)?;
let col = offset - line_start_offset; let col = offset - start;
let ret = LineCol { line: line as u32, col: col.into() }; let ret = LineCol { line: line as u32, col: col.into() };
self.line_wide_chars self.line_wide_chars
.get(&ret.line) .get(&ret.line)