internal/lsp: make sure completion items are never null

Change-Id: Ic6e0988319f8fb2c91b473ac2fa5480dc25dc0b7
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167158
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
This commit is contained in:
Rebecca Stambler 2019-03-12 12:53:45 -04:00
parent 7b79afddac
commit e65039ee41
1 changed files with 1 additions and 1 deletions

View File

@ -22,7 +22,7 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
sort.SliceStable(candidates, func(i, j int) bool { sort.SliceStable(candidates, func(i, j int) bool {
return candidates[i].Score > candidates[j].Score return candidates[i].Score > candidates[j].Score
}) })
var items []protocol.CompletionItem items := []protocol.CompletionItem{}
for i, candidate := range candidates { for i, candidate := range candidates {
// Matching against the label. // Matching against the label.
if !strings.HasPrefix(candidate.Label, prefix) { if !strings.HasPrefix(candidate.Label, prefix) {