Update crates/ruff_source_file/src/locator.rs

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
konsti 2023-09-26 14:05:04 +02:00 committed by GitHub
parent f39e8af8ae
commit 59c37d0cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 7 deletions

View File

@ -504,13 +504,7 @@ impl<'a> Locator<'a> {
/// assert_eq!(&source[TextRange::new(offset, source.text_len())], "腐'"); /// assert_eq!(&source[TextRange::new(offset, source.text_len())], "腐'");
/// ``` /// ```
pub fn convert_row_and_column_utf16(&self, row: usize, column: usize) -> Option<TextSize> { pub fn convert_row_and_column_utf16(&self, row: usize, column: usize) -> Option<TextSize> {
let line_start = *self.to_index().line_starts().get(row)?; let line_range = *self.to_index().line_range(row)
let next_line_start = self
.to_index()
.line_starts()
.get(row + 1)
.copied()
.unwrap_or(self.contents.text_len());
let line_contents = &self.contents[TextRange::from(line_start..next_line_start)]; let line_contents = &self.contents[TextRange::from(line_start..next_line_start)];
let mut len_bytes = TextSize::default(); let mut len_bytes = TextSize::default();