diff --git a/gopls/internal/regtest/completion_test.go b/gopls/internal/regtest/completion_test.go index 5978f56a4ff..2651f590064 100644 --- a/gopls/internal/regtest/completion_test.go +++ b/gopls/internal/regtest/completion_test.go @@ -193,54 +193,6 @@ package ma }) } -// Test the order of completion suggestions -func TestStructLiteralCompletion(t *testing.T) { - const files = ` --- go.mod -- -module mod.com - --- foo.go -- -package foo - -type Foo struct { - c int - b int - a int -} - -func f() { - foo := Foo{ - - } -} -` - - want := []string{"c", "b", "a"} - - run(t, files, func(t *testing.T, env *Env) { - env.OpenFile("foo.go") - completions := env.Completion("foo.go", fake.Pos{ - Line: 10, - Column: 0, - }) - - diff := compareCompletionResultsOnlyHead(want, completions.Items) - if diff != "" { - t.Fatal(diff) - return - } - }) -} - -func compareCompletionResultsOnlyHead(want []string, gotItems []protocol.CompletionItem) string { - for i := range want { - if want[i] != gotItems[i].Label { - return fmt.Sprintf("completion results are not the same: got %v, want %v", gotItems[i].Label, want[i]) - } - } - return "" -} - func compareCompletionResults(want []string, gotItems []protocol.CompletionItem) string { if len(gotItems) != len(want) { return fmt.Sprintf("got %v completion(s), want %v", len(gotItems), len(want)) diff --git a/internal/lsp/testdata/rank/struct/struct_rank.go b/internal/lsp/testdata/rank/struct/struct_rank.go new file mode 100644 index 00000000000..e0bdd38a87d --- /dev/null +++ b/internal/lsp/testdata/rank/struct/struct_rank.go @@ -0,0 +1,11 @@ +package struct_rank + +type foo struct { + c int //@item(c_rank, "c", "int", "field") + b int //@item(b_rank, "b", "int", "field") + a int //@item(a_rank, "a", "int", "field") +} + +func f() { + foo := foo{} //@rank("}", c_rank, b_rank, a_rank) +} diff --git a/internal/lsp/testdata/summary.txt.golden b/internal/lsp/testdata/summary.txt.golden index 3771c8532b7..f10805cbdf0 100644 --- a/internal/lsp/testdata/summary.txt.golden +++ b/internal/lsp/testdata/summary.txt.golden @@ -6,7 +6,7 @@ CompletionSnippetCount = 85 UnimportedCompletionsCount = 5 DeepCompletionsCount = 5 FuzzyCompletionsCount = 8 -RankedCompletionsCount = 157 +RankedCompletionsCount = 158 CaseSensitiveCompletionsCount = 4 DiagnosticsCount = 43 FoldingRangesCount = 2