WorkspaceMapping

Maps positions from the document version a request was issued against to the current document version.

Ports upstream @codemirror/lsp-client's WorkspaceMapping. An LSP request is sent against a particular document version; by the time the response comes back the editor may have moved on through further edits. Positions returned by the server are expressed against the version the request saw, so they must be mapped through the edits that happened in the meantime before they are used in the (now-current) editor.

Obtain one via Workspace.getMapping. The mapping is a live view: it tracks edits applied to the file after it was created, so a request handler can capture the mapping when it issues the request and use it once the response arrives.

Parameters

uri

The URI of the file whose positions this mapping translates.

Properties

Link copied to clipboard
val uri: String

Functions

Link copied to clipboard
fun mapPos(pos: Int, assoc: Int = -1): Int

Map a document offset issued against the request-time document to the current document.

Link copied to clipboard
fun mapPosition(lspPos: Position, prevDoc: Text, assoc: Int = -1): Int

Map an LSP Position from the request-time document to a current-document offset.