Skip to content

@jsvision/code-editor / offsetToPosition

Function: offsetToPosition()

offsetToPosition(snapshot, offset): DocumentPosition

Defined in: code-editor/src/document/positions.ts:30

Converts a UTF-16 document offset to a zero-based line and character.

Parameters

snapshot

DocumentSnapshot

offset

number

Returns

DocumentPosition

Example

ts
const position = offsetToPosition(snapshot, 4);