Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide_db/src/line_index.rs')
| -rw-r--r-- | crates/ide_db/src/line_index.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ide_db/src/line_index.rs b/crates/ide_db/src/line_index.rs index 816edfe6a8..35e1757eae 100644 --- a/crates/ide_db/src/line_index.rs +++ b/crates/ide_db/src/line_index.rs @@ -102,8 +102,10 @@ impl LineIndex { LineCol { line: line as u32, col: col.into() } } - pub fn offset(&self, line_col: LineCol) -> TextSize { - self.newlines[line_col.line as usize] + TextSize::from(line_col.col) + pub fn offset(&self, line_col: LineCol) -> Option<TextSize> { + self.newlines + .get(line_col.line as usize) + .map(|offset| offset + TextSize::from(line_col.col)) } pub fn to_utf16(&self, line_col: LineCol) -> LineColUtf16 { |