Expand description
Minimal text indexing for LSP position math (replaces ropey). Minimal text indexing for LSP position math.
Replaces our previous use of [ropey]. We never actually used ropey for what
ropey is for — incremental edits and cheap snapshots — because the server
uses full-document sync and rebuilds the buffer from a String on every
change. The only thing we used was index conversion, and ropey hid the one
decision that actually matters for correctness: which encoding a column is
measured in.
LineIndex makes that explicit. It owns the source text plus a table of
line-start byte offsets, and every conversion takes a PositionEncoding so
the byte/UTF-16 choice is visible at the call site instead of buried in a
dependency.
§Encodings
An LSP Position.character is a count from the start of its line. The unit
depends on the negotiated PositionEncoding:
PositionEncoding::Utf16— UTF-16 code units. This is the LSP default and what clients assume unless the server negotiates otherwise.PositionEncoding::Utf8— bytes. Cheapest, and what this codebase used to emit unconditionally (correct only for ASCII).
Internally everything is a UTF-8 byte offset; encodings only ever affect the in-line column number.
Structs§
Enums§
- Position
Encoding - The unit in which an LSP
Position.charactercolumn is measured.