pub struct LineIndex { /* private fields */ }Expand description
Precomputed line start offsets for fast byte-offset-to-position conversion.
Construction is O(n) where n is the text length. Each position lookup is O(log L + k) where L is the number of lines and k is the byte length from the line start to the target offset.
Implementations§
Source§impl LineIndex
impl LineIndex
Sourcepub fn byte_offset_to_position(&self, text: &str, offset: usize) -> (u32, u32)
pub fn byte_offset_to_position(&self, text: &str, offset: usize) -> (u32, u32)
Converts a byte offset to an LSP-compatible (line, character) pair.
line: 0-based line numbercharacter: 0-based UTF-16 code unit offset from line start
If offset exceeds the text length, it is clamped to text.len().
Auto Trait Implementations§
impl Freeze for LineIndex
impl RefUnwindSafe for LineIndex
impl Send for LineIndex
impl Sync for LineIndex
impl Unpin for LineIndex
impl UnsafeUnpin for LineIndex
impl UnwindSafe for LineIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more