fromPosition

fun fromPosition(pos: Position, doc: Text): Int

Convert an LSP Position to a kodemirror document offset.

Ports upstream @codemirror/lsp-client's LSPPlugin.fromPosition. The line is 1-based in kodemirror but 0-based in LSP, and character is a UTF-16 code-unit offset within the line. Out-of-range line/character values are clamped to the document, mirroring the LSP spec.

Parameters

pos

The LSP position to convert.

doc

The document the position refers to.