helper

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPosition = errors.New("no position")

Functions

func BytePositionToUTF16Position added in v0.8.0

func BytePositionToUTF16Position(src string, pos lsp.Position) lsp.Position

BytePositionToUTF16Position converts a byte-column position into the UTF-16-column position an LSP client expects.

func GetLspPosition

func GetLspPosition(files map[lsp.DocumentURI]string) (formattedFiles map[lsp.DocumentURI]string, path lsp.DocumentURI, position lsp.Position, err error)

func GetUTF16LspPosition added in v0.8.0

func GetUTF16LspPosition(files map[lsp.DocumentURI]string) (formattedFiles map[lsp.DocumentURI]string, path lsp.DocumentURI, position lsp.Position, err error)

GetUTF16LspPosition is GetLspPosition with the cursor Character counted in UTF-16 code units, i.e. what an LSP client would send.

func IndexToPosition

func IndexToPosition(file string, index int) lsp.Position

func UTF16PositionToBytePosition added in v0.8.0

func UTF16PositionToBytePosition(src string, pos lsp.Position) lsp.Position

UTF16PositionToBytePosition converts a position received from an LSP client into the byte-column position the source package works with.

Types

type PositionConverter added in v0.8.0

type PositionConverter struct {
	// contains filtered or unexported fields
}

PositionConverter converts positions between byte columns, which the source package works with, and UTF-16 code unit columns, which LSP clients use by default. It splits src once so that converting many positions of the same file stays linear.

func NewPositionConverter added in v0.8.0

func NewPositionConverter(src string) PositionConverter

func (PositionConverter) FromUTF16 added in v0.8.0

func (c PositionConverter) FromUTF16(pos lsp.Position) lsp.Position

FromUTF16 converts a UTF-16-column position. A column past the end of its line is clamped to the line end; a line outside src is returned unchanged.

func (PositionConverter) RangeToUTF16 added in v0.8.0

func (c PositionConverter) RangeToUTF16(r lsp.Range) lsp.Range

func (PositionConverter) ToUTF16 added in v0.8.0

func (c PositionConverter) ToUTF16(pos lsp.Position) lsp.Position

ToUTF16 converts a byte-column position. A column past the end of its line is clamped to the line end; a line outside src is returned unchanged.

Jump to

Keyboard shortcuts

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