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

internal/lsp: fix completion ordering workaround

Our loop to make all candidates use the same "filterText" wasn't
including the final candidate. This was causing strange ordering of
candidates in VSCode when the "worst" candidate happened to match the
prefix exactly (causing VSCode to reorder it to the top).

Fixes golang/go#36519.

Change-Id: Ie2119ca94d13f337edd241fbde862706bdeee191
Reviewed-on: https://go-review.googlesource.com/c/tools/+/214184
Run-TryBot: Muir Manders <muir@mnd.rs>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Muir Manders 2020-01-12 19:27:12 -08:00 committed by Rebecca Stambler
parent a7a6caa82a
commit eac381796e

View File

@ -66,9 +66,9 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara
items := toProtocolCompletionItems(candidates, rng, options)
if incompleteResults && len(items) > 1 {
for i := range items[1:] {
// Give all the candidaites the same filterText to trick VSCode
if incompleteResults {
for i := 1; i < len(items); i++ {
// Give all the candidates the same filterText to trick VSCode
// into not reordering our candidates. All the candidates will
// appear to be equally good matches, so VSCode's fuzzy
// matching/ranking just maintains the natural "sortText"