position

package
v0.1.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteOffsetToUTF16

func ByteOffsetToUTF16(s string, byteOffset int) int

ByteOffsetToUTF16 converts a byte offset to a UTF-16 code unit offset in a string. This is the inverse of UTF16ToByteOffset and is useful for converting positions from Go's byte-based indexing to LSP's UTF-16 positions.

func ByteOffsetToUTF16Uint32 added in v0.1.19

func ByteOffsetToUTF16Uint32(s string, byteOffset int) uint32

ByteOffsetToUTF16Uint32 is like ByteOffsetToUTF16 but returns uint32 for LSP compatibility. Clamps the result to valid uint32 range.

func StringLengthUTF16

func StringLengthUTF16(s string) int

StringLengthUTF16 returns the length of a string in UTF-16 code units. This is useful for calculating ranges and validating positions.

func StringLengthUTF16Uint32 added in v0.1.19

func StringLengthUTF16Uint32(s string) uint32

StringLengthUTF16Uint32 is like StringLengthUTF16 but returns uint32 for LSP compatibility. Clamps the result to valid uint32 range.

func UTF16ToByteOffset

func UTF16ToByteOffset(s string, utf16Col int) int

UTF16ToByteOffset converts a UTF-16 code unit offset to a byte offset in a string. LSP positions use UTF-16 code units, but Go strings are UTF-8 byte sequences. This function handles surrogate pairs correctly (characters > U+FFFF count as 2 UTF-16 units).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL