internal/lsp: fix utf16 conversion for end of file cursor

Also remove error case that can no longer happen and the related test.

Fixes golang/go#31341

Change-Id: I534956f6e835dea4334b68d0ad0297cf93920af2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/173960
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
diff --git a/internal/span/utf16.go b/internal/span/utf16.go
index ee012d0..97c06c9 100644
--- a/internal/span/utf16.go
+++ b/internal/span/utf16.go
@@ -40,9 +40,6 @@
 	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 544ceaa..32e9568 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
@@ -90,14 +87,6 @@
 		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,
 		line:        2,
@@ -126,7 +115,6 @@
 		resUTF16col: 5,  // 2 + 1 + 1 + 1 (1-indexed)
 		pre:         "𐐀45",
 		post:        "",
-		issue:       b31341,
 	},
 	{
 		scenario: "cursor beyond end of file",