pub struct LineOffsetTable { /* private fields */ }Expand description
Converts byte offsets in source text to LSP Position values.
Precomputes line-start byte offsets once, then maps any byte offset to a
(line, character) position. Characters are counted as UTF-16 code units
as required by the LSP specification.
Implementations§
Source§impl LineOffsetTable
impl LineOffsetTable
Sourcepub fn new(content: &str) -> LineOffsetTable
pub fn new(content: &str) -> LineOffsetTable
Builds the table for content.
Sourcepub fn byte_offset_to_position(&self, content: &str, offset: usize) -> Position
pub fn byte_offset_to_position(&self, content: &str, offset: usize) -> Position
Converts a byte offset into an LSP Position.
Auto Trait Implementations§
impl Freeze for LineOffsetTable
impl RefUnwindSafe for LineOffsetTable
impl Send for LineOffsetTable
impl Sync for LineOffsetTable
impl Unpin for LineOffsetTable
impl UnsafeUnpin for LineOffsetTable
impl UnwindSafe for LineOffsetTable
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