helpers

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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PositionToUTF16

func PositionToUTF16(source string, point sitter.Point) (protocol.Position, error)

PositionToUTF16 converts a tree-sitter Point (which uses byte offsets for Column) to LSP Position (which uses UTF-16 code units for Character).

Returns an error if the position exceeds uint32 limits (LSP protocol limitation). This should never happen with normal text files, but guards against parser corruption.

func RangesIntersect

func RangesIntersect(a, b protocol.Range) bool

RangesIntersect checks if two LSP ranges intersect. Ranges are treated as half-open intervals [start, end) where the end position is exclusive.

Returns true if the ranges overlap, false otherwise.

Examples:

  • [0:0, 0:5) and [0:3, 0:7) -> true (overlap from 0:3 to 0:5)
  • [0:0, 0:5) and [0:5, 0:10) -> false (adjacent but not overlapping)
  • [0:0, 1:0) and [0:5, 0:10) -> true (first range includes line 0:5)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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