diff --git a/internal/span/utf16.go b/internal/span/utf16.go index ee012d02..97c06c95 100644 --- a/internal/span/utf16.go +++ b/internal/span/utf16.go @@ -40,9 +40,6 @@ func ToUTF16Column(p Point, content []byte) (int, error) { start := content[lineOffset:] // Now, truncate down to the supplied column. - if col > len(start) { // col is 1-indexed - return -1, fmt.Errorf("ToUTF16Column: length of line (%v) is less than column (%v)", len(start), col) - } start = start[:col] // and count the number of utf16 characters // in theory we could do this by hand more efficiently... diff --git a/internal/span/utf16_test.go b/internal/span/utf16_test.go index 544ceaa2..32e95683 100644 --- a/internal/span/utf16_test.go +++ b/internal/span/utf16_test.go @@ -5,15 +5,12 @@ package span_test import ( - "flag" "strings" "testing" "golang.org/x/tools/internal/span" ) -var b31341 = flag.Bool("b31341", false, "Test for issue 31341") - // The funny character below is 4 bytes long in UTF-8; two UTF-16 code points var funnyString = []byte(` 𐐀23 @@ -89,14 +86,6 @@ var toUTF16Tests = []struct { pre: "𐐀23", post: "", }, - { - scenario: "cursor beyond last character on first line", - input: funnyString, - line: 1, - col: 7, // 4 + 1 + 1 + 1 (1-indexed) - offset: 13, // 4 + 1 + 1 - err: "ToUTF16Column: length of line (6) is less than column (7)", - }, { scenario: "cursor before funny character; second line", input: funnyString, @@ -126,7 +115,6 @@ var toUTF16Tests = []struct { resUTF16col: 5, // 2 + 1 + 1 + 1 (1-indexed) pre: "𐐀45", post: "", - issue: b31341, }, { scenario: "cursor beyond end of file",