vendor tsgo

This commit is contained in:
2026-07-09 16:50:43 -04:00
parent c06ea2e5a4
commit 98978e4930
5804 changed files with 1556156 additions and 101 deletions

View File

@@ -0,0 +1,37 @@
package lsproto
import (
"cmp"
)
// Implements a cmp.Compare like function for two Position
// ComparePositions(pos, other) == cmp.Compare(pos, other)
func ComparePositions(pos, other Position) int {
if lineComp := cmp.Compare(pos.Line, other.Line); lineComp != 0 {
return lineComp
}
return cmp.Compare(pos.Character, other.Character)
}
// Implements a cmp.Compare like function for two Range
// CompareRanges(lsRange, other) == cmp.Compare(lsRange, other)
//
// Range.Start is compared before Range.End
func CompareRanges(lsRange, other Range) int {
if startComp := ComparePositions(lsRange.Start, other.Start); startComp != 0 {
return startComp
}
return ComparePositions(lsRange.End, other.End)
}
// AsString returns the plain text of a StringOrMarkupContent, reading the
// MarkupContent value when the message is not a plain string.
func (m StringOrMarkupContent) AsString() string {
if m.String != nil {
return *m.String
}
if m.MarkupContent != nil {
return m.MarkupContent.Value
}
return ""
}