Add offset method to ruff_python_trivia::Cursor (#18371)

This commit is contained in:
Alex Waygood
2025-05-29 16:08:15 +01:00
committed by GitHub
parent 33ed502edb
commit 7df79cfb70
3 changed files with 25 additions and 29 deletions

View File

@@ -21,6 +21,11 @@ impl<'a> Cursor<'a> {
}
}
/// Retrieves the current offset of the cursor within the source code.
pub fn offset(&self) -> TextSize {
self.source_length - self.text_len()
}
/// Return the remaining input as a string slice.
pub fn chars(&self) -> Chars<'a> {
self.chars.clone()