1
0
mirror of https://github.com/golang/go synced 2024-11-18 18:44:42 -07:00

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>
This commit is contained in:
Muir Manders 2019-09-13 22:13:55 -07:00 committed by Rebecca Stambler
parent fff8d94173
commit bb199b9d33
3 changed files with 6 additions and 13 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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