-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/lsp: enable deep completion and fuzzy matching by default
Invert "useDeepCompletions" config flag to "disableDeepCompletion" and separate out "disableFuzzyMatching" which reverts to the previous prefix matching behavior. I separated fuzzy matching tests out to a separate file so they aren't entangled with deep completion tests. In coming up with representative test cases I found a couple issues which I fixed: - We were treating a fuzzy matcher score of 0 as no match, but the matcher returns 0 for candidates that match but have no bonuses. I changed the matcher interface so that a score of 0 counts as a match. For example, this was preventing a pattern of "o" from matching "foo". - When we lower a candidate's score based on its depth, we were subtracting a static multiplier which could result in the score going negative. A negative score messes up future score weighting because multiplying it by a value in the range [0, 1) makes it bigger instead of smaller. Fix by scaling a candidate's score based on its depth rather than subtracting a constant factor. Updates golang/go#32754 Change-Id: Ie6f9111f1696b0d067d08f7eed7b0a338ad9cd67 Reviewed-on: https://go-review.googlesource.com/c/tools/+/192137 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
- Loading branch information
1 parent
c17b040
commit 6afc7fc
Showing
9 changed files
with
115 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
internal/lsp/testdata/deepcomplete/fuzzymatch/deep_fuzzy.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2019 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package fuzzymatch | ||
|
||
func _() { | ||
var a struct { | ||
fabar int | ||
fooBar string | ||
} | ||
|
||
a.fabar //@item(fuzzFabarField, "a.fabar", "int", "field") | ||
a.fooBar //@item(fuzzFooBarField, "a.fooBar", "string", "field") | ||
|
||
afa //@complete(" //", fuzzFabarField, fuzzFooBarField) | ||
afb //@complete(" //", fuzzFooBarField, fuzzFabarField) | ||
|
||
fab //@complete(" //", fuzzFabarField) | ||
|
||
o //@complete(" //", fuzzFooBarField) | ||
|
||
var myString string | ||
myString = ar //@complete(" //", fuzzFooBarField, fuzzFabarField) | ||
|
||
var b struct { | ||
c struct { | ||
d struct { | ||
e struct { | ||
abc string | ||
} | ||
abc float32 | ||
} | ||
abc bool | ||
} | ||
abc int | ||
} | ||
|
||
b.abc //@item(fuzzABCInt, "b.abc", "int", "field") | ||
b.c.abc //@item(fuzzABCbool, "b.c.abc", "bool", "field") | ||
b.c.d.abc //@item(fuzzABCfloat, "b.c.d.abc", "float32", "field") | ||
b.c.d.e.abc //@item(fuzzABCstring, "b.c.d.e.abc", "string", "field") | ||
|
||
// in depth order by default | ||
abc //@complete(" //", fuzzABCInt, fuzzABCbool, fuzzABCfloat) | ||
|
||
// deep candidate that matches expected type should still ranked first | ||
var s string | ||
s = abc //@complete(" //", fuzzABCstring, fuzzABCInt, fuzzABCbool) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters