toPosition

fun toPosition(offset: Int, doc: Text): Position

Convert a kodemirror document offset to an LSP Position.

Ports upstream @codemirror/lsp-client's LSPPlugin.toPosition. LSP positions are {line, character} pairs where line is 0-based and character is a 0-based UTF-16 code-unit offset within that line. Kotlin String/Char are already UTF-16 code units, so within a line the offset is a direct character index.

Parameters

offset

The document offset (a 0-based character offset).

doc

The document the offset refers to.