Skip to main content

byte_to_lsp_character

Function byte_to_lsp_character 

Source
pub fn byte_to_lsp_character(
    line: &str,
    byte: u32,
    encoding: &PositionEncodingKind,
) -> u32
Expand description

Convert a UTF-8 byte offset within line to the offset in the negotiated encoding. Used when constructing LSP Position::character from lattice’s Position::byte.

Bounds: byte may equal line.len() (one-past-the-end); callers passing larger values get the count for the whole line plus their over-shoot, matching Rust’s &str slicing semantics.