Skip to main content

Module position

Module position 

Source
Expand description

Turning the positions the LSP speaks in into offsets into a file.

A position is a line and a column, both counted from zero, and the column is counted in UTF-16 code units – not bytes, and not characters. For a line of ASCII all three agree, which is why the difference is easy to miss and unforgiving when it bites: on a line with an accented letter the byte offset runs ahead, and on one with an emoji the UTF-16 count does.

Functions§

byte_offset
The byte offset of the LSP position (line, character) in text.