Skip to main content

position_to_byte_offset

Function position_to_byte_offset 

Source
pub fn position_to_byte_offset(source: &str, pos: Position) -> usize
Expand description

Convert an LSP Position position back to a byte offset, where character is interpreted according to the negotiated PositionEncoding.

Uses a single SIMD-accelerated pass with compute_indices to build a coarse index of the file at 128-byte intervals, then does a short linear walk (at most 128 bytes) with TextIndex::advance to find the exact byte offset.