aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/regtest/completion/completion18_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gopls/internal/regtest/completion/completion18_test.go')
-rw-r--r--gopls/internal/regtest/completion/completion18_test.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/gopls/internal/regtest/completion/completion18_test.go b/gopls/internal/regtest/completion/completion18_test.go
index 9683e30c8..18e81bc4b 100644
--- a/gopls/internal/regtest/completion/completion18_test.go
+++ b/gopls/internal/regtest/completion/completion18_test.go
@@ -10,7 +10,8 @@ package completion
import (
"testing"
- . "golang.org/x/tools/internal/lsp/regtest"
+ "golang.org/x/tools/gopls/internal/lsp/protocol"
+ . "golang.org/x/tools/gopls/internal/lsp/regtest"
)
// test generic receivers
@@ -41,10 +42,10 @@ func (s SyncMap[XX,string]) g(v UU) {}
env.OpenFile("main.go")
env.Await(env.DoneWithOpen())
for _, tst := range tests {
- pos := env.RegexpSearch("main.go", tst.pat)
- pos.Column += len(tst.pat)
- completions := env.Completion("main.go", pos)
- result := compareCompletionResults(tst.want, completions.Items)
+ loc := env.RegexpSearch("main.go", tst.pat)
+ loc.Range.Start.Character += uint32(protocol.UTF16Len([]byte(tst.pat)))
+ completions := env.Completion(loc)
+ result := compareCompletionLabels(tst.want, completions.Items)
if result != "" {
t.Errorf("%s: wanted %v", result, tst.want)
for i, g := range completions.Items {
@@ -95,7 +96,7 @@ func FuzzHex(f *testing.F) {
tests := []struct {
file string
pat string
- offset int // from the beginning of pat to what the user just typed
+ offset uint32 // UTF16 length from the beginning of pat to what the user just typed
want []string
}{
{"a_test.go", "f.Ad", 3, []string{"Add"}},
@@ -108,10 +109,10 @@ func FuzzHex(f *testing.F) {
for _, test := range tests {
env.OpenFile(test.file)
env.Await(env.DoneWithOpen())
- pos := env.RegexpSearch(test.file, test.pat)
- pos.Column += test.offset // character user just typed? will type?
- completions := env.Completion(test.file, pos)
- result := compareCompletionResults(test.want, completions.Items)
+ loc := env.RegexpSearch(test.file, test.pat)
+ loc.Range.Start.Character += test.offset // character user just typed? will type?
+ completions := env.Completion(loc)
+ result := compareCompletionLabels(test.want, completions.Items)
if result != "" {
t.Errorf("pat %q %q", test.pat, result)
for i, it := range completions.Items {