UTF-16 Utilities #
Convert a UTF-8 byte offset to a UTF-16 offset within a string
Equations
- Lapis.VFS.Position.utf8OffsetToUtf16 s utf8Offset = Lapis.VFS.Position.utf8OffsetToUtf16.utf8ToUtf16Aux utf8Offset s 0 0 0
Instances For
Convert a UTF-16 offset to a UTF-8 byte offset within a string
Equations
- Lapis.VFS.Position.utf16OffsetToUtf8 s utf16Offset = Lapis.VFS.Position.utf16OffsetToUtf8.utf16ToUtf8Aux utf16Offset s 0 0 0
Instances For
Get the UTF-8 byte length up to a character index
Equations
- Lapis.VFS.Position.utf8BytesUpToChar s charIdx = Lapis.VFS.Position.utf8BytesUpToChar.bytesUpToCharAux charIdx s 0 0
Instances For
LSP Position Type #
LSP Position (0-indexed line and UTF-16 character offset)
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
Instances For
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Lapis.VFS.Position.LspPosition.zero = { line := 0, character := 0 }
Instances For
Equations
Instances For
Create a range from a single position (zero-width)
Equations
- Lapis.VFS.Position.LspRange.point pos = { start := pos, «end» := pos }
Instances For
Position Conversion Context #
Context needed for position conversions
- pieceTable : PieceTable.PieceTableState
- lineIndex : LineIndex.LineIndex
Instances For
Equations
Instances For
Get the line content as a string
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Lapis.VFS.Position.ConversionContext.getLineContentTrimmed
(ctx : ConversionContext)
(line : Nat)
:
Get line content up to (but not including) the newline
Equations
- One or more equations did not get rendered due to their size.
Instances For
Position to Byte Offset #
Convert an LSP position to a byte offset
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert a byte offset to an LSP position
Equations
- One or more equations did not get rendered due to their size.
Instances For
Range Conversions #
Convert an LSP range to a byte range
Equations
- One or more equations did not get rendered due to their size.
Instances For
Convert a byte range to an LSP range
Equations
- Lapis.VFS.Position.byteRangeToRange ctx startByte endByte = { start := Lapis.VFS.Position.byteOffsetToPosition ctx startByte, «end» := Lapis.VFS.Position.byteOffsetToPosition ctx endByte }
Instances For
Offset Utilities #
Clamp a byte offset to valid document bounds
Equations
- Lapis.VFS.Position.clampOffset ctx offset = min offset ctx.pieceTable.byteLength
Instances For
Check if a position is valid for the document
Equations
- One or more equations did not get rendered due to their size.
Instances For
Get the position at the end of the document
Equations
Instances For
Get the position at the end of a specific line
Equations
- Lapis.VFS.Position.endOfLine ctx line = match ctx.getLineContentTrimmed line with | none => none | some content => some { line := line, character := Lapis.VFS.Position.utf16Length content }