Skip to content

@jsvision/code-editor / positionToOffset

Function: positionToOffset()

positionToOffset(snapshot, position): DocumentOffset

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

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

Parameters

snapshot

DocumentSnapshot

position

DocumentPositionInput

Returns

DocumentOffset

Example

ts
const offset = positionToOffset(snapshot, { line: 1, character: 2 });