diff --git a/internal/span/utf16.go b/internal/span/utf16.go index 5f90a51b01..55e6924889 100644 --- a/internal/span/utf16.go +++ b/internal/span/utf16.go @@ -69,7 +69,11 @@ func FromUTF16Column(p Point, chr int, content []byte) (Point, error) { } r, w := utf8.DecodeRune(remains) if r == '\n' { - return Point{}, fmt.Errorf("FromUTF16Column: chr goes beyond the line") + // Per the LSP spec: + // + // > If the character value is greater than the line length it + // > defaults back to the line length. + break } remains = remains[w:] if r >= 0x10000 { diff --git a/internal/span/utf16_test.go b/internal/span/utf16_test.go index 2762772cd1..0ae274916d 100644 --- a/internal/span/utf16_test.go +++ b/internal/span/utf16_test.go @@ -185,12 +185,15 @@ var fromUTF16Tests = []struct { post: "", }, { - scenario: "cursor beyond last character on line", - input: funnyString, - line: 1, - offset: 0, - utf16col: 6, - err: "FromUTF16Column: chr goes beyond the line", + scenario: "cursor beyond last character on line", + input: funnyString, + line: 1, + offset: 0, + utf16col: 6, + resCol: 7, + resOffset: 6, + pre: "𐐀23", + post: "", }, { scenario: "cursor before funny character; second line",