Skip to main content

Module position

Module position 

Source
Expand description

Char offsets in, protocol positions out.

The editor counts chars (ADR-0006 §1); the language protocol counts UTF-16 code units within a line. Conversion lives here because this crate owns the rope, which keeps termesh-lsp rope-free and trading only in TextPosition.

Functions§

offset_from_utf16
The char offset for a protocol position, clamped to the line and to the document. Servers do send out-of-range positions; clamping is the contract, not a bug.
utf16_position
(line, character) for a char offset, with character in UTF-16 code units.