diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go index c5a85c5488..9c64de9e28 100644 --- a/internal/lsp/source/completion.go +++ b/internal/lsp/source/completion.go @@ -119,9 +119,9 @@ const ( 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 @@ func (c *completer) found(obj types.Object, score float64, imp *imports.ImportIn 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 26f1e3affb..747f96614e 100644 --- a/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go +++ b/internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go @@ -18,10 +18,8 @@ func _() { 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 9a97b039f8..4658362441 100644 --- a/internal/lsp/tests/tests.go +++ b/internal/lsp/tests/tests.go @@ -30,7 +30,7 @@ import ( // 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