internal/lsp: reduce completion candidate volume

Revert my previous change to include fuzzy matches with a score of
zero. Zero scorers have some characters that match, but they are
pretty poor overall. Pulling in all the extra junk candidates was
slowing things down in certain cases.

Change-Id: I560f46903281f21b0628c9b14848cddf1e3c0a38
Reviewed-on: https://go-review.googlesource.com/c/tools/+/195418
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go
index c5a85c5..9c64de9 100644
--- a/internal/lsp/source/completion.go
+++ b/internal/lsp/source/completion.go
@@ -119,9 +119,9 @@
 	completionBudget = 100 * time.Millisecond
 )
 
-// matcher matches a candidate's label against the user input.  The
-// returned score reflects the quality of the match. A score less than
-// zero indicates no match, and a score of one means a perfect match.
+// matcher matches a candidate's label against the user input. The
+// returned score reflects the quality of the match. A score of zero
+// indicates no match, and a score of one means a perfect match.
 type matcher interface {
 	Score(candidateLabel string) (score float32)
 }
@@ -324,12 +324,7 @@
 
 	cand.name = c.deepState.chainString(obj.Name())
 	matchScore := c.matcher.Score(cand.name)
-	if matchScore >= 0 {
-		// Avoid a score of zero since that homogenizes all candidates.
-		if matchScore == 0 {
-			matchScore = 0.001
-		}
-
+	if matchScore > 0 {
 		cand.score *= float64(matchScore)
 
 		// Avoid calling c.item() for deep candidates that wouldn't be in the top
diff --git a/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go b/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go
index 26f1e3a..747f966 100644
--- a/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go
+++ b/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go
@@ -18,10 +18,8 @@
 
 	fab //@complete(" //", fuzzFabarField)
 
-	o //@complete(" //", fuzzFooBarField)
-
 	var myString string
-	myString = ar //@complete(" //", fuzzFooBarField, fuzzFabarField)
+	myString = af //@complete(" //", fuzzFooBarField, fuzzFabarField)
 
 	var b struct {
 		c struct {
diff --git a/internal/lsp/tests/tests.go b/internal/lsp/tests/tests.go
index 9a97b03..4658362 100644
--- a/internal/lsp/tests/tests.go
+++ b/internal/lsp/tests/tests.go
@@ -30,7 +30,7 @@
 // We hardcode the expected number of test cases to ensure that all tests
 // are being executed. If a test is added, this number must be changed.
 const (
-	ExpectedCompletionsCount       = 163
+	ExpectedCompletionsCount       = 162
 	ExpectedCompletionSnippetCount = 16
 	ExpectedDiagnosticsCount       = 21
 	ExpectedFormatCount            = 6