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

internal/lsp: stop providing insertText for completion items

InsertText is deprecated, and it seems that providing both InsertText
and TextEdits causes unexpected behavior from VSCode. Avoid this by
providing only TextEdits.

Fixes golang/go#30796

Change-Id: Ieb5ad2fecd6f7083a4c1bc402634893c7e6ff49f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/167457
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rebecca Stambler 2019-03-13 14:25:56 -04:00
parent 516ab0aa77
commit d55b9fb8ef

View File

@ -28,15 +28,17 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
if !strings.HasPrefix(candidate.Label, prefix) {
continue
}
// InsertText is deprecated in favor of TextEdits.
// TODO(rstambler): Remove this logic when we are confident that we no
// longer need to support it.
insertText, triggerSignatureHelp := labelToProtocolSnippets(candidate.Label, candidate.Kind, insertTextFormat, signatureHelpEnabled)
if strings.HasPrefix(insertText, prefix) {
insertText = insertText[len(prefix):]
}
item := protocol.CompletionItem{
Label: candidate.Label,
Detail: candidate.Detail,
Kind: toProtocolCompletionItemKind(candidate.Kind),
InsertTextFormat: protocol.PlainTextTextFormat,
Label: candidate.Label,
Detail: candidate.Detail,
Kind: toProtocolCompletionItemKind(candidate.Kind),
TextEdit: &protocol.TextEdit{
NewText: insertText,
Range: protocol.Range{
@ -44,8 +46,6 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
End: pos,
},
},
// InsertText is deprecated in favor of TextEdit.
InsertText: insertText,
// This is a hack so that the client sorts completion results in the order
// according to their score. This can be removed upon the resolution of
// https://github.com/Microsoft/language-server-protocol/issues/348.