Expand description
Byte-offset ↔ LSP position conversion.
Bynk source spans are byte offsets into the UTF-8 source. LSP positions use UTF-16 code units (per the protocol’s default position encoding). For ASCII-only Bynk sources the two agree, but we go through code points to handle multi-byte characters correctly in identifiers and strings.
Functions§
- end_
position - The position one past the end of the source — used for “replace whole document” formatting edits.
- offset_
to_ position - Convert a byte offset into the source string into an LSP position.
- position_
to_ offset - Convert an LSP position into a byte offset. Returns None if the position is past the end of the source.
- span_
to_ range - Convert a compiler
Spaninto an LSP [Range]. - utf8_
char_ 🔒len