mirror of
https://github.com/golang/go
synced 2024-11-18 19:14:40 -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:
parent
516ab0aa77
commit
d55b9fb8ef
@ -28,15 +28,17 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
|
|||||||
if !strings.HasPrefix(candidate.Label, prefix) {
|
if !strings.HasPrefix(candidate.Label, prefix) {
|
||||||
continue
|
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)
|
insertText, triggerSignatureHelp := labelToProtocolSnippets(candidate.Label, candidate.Kind, insertTextFormat, signatureHelpEnabled)
|
||||||
if strings.HasPrefix(insertText, prefix) {
|
if strings.HasPrefix(insertText, prefix) {
|
||||||
insertText = insertText[len(prefix):]
|
insertText = insertText[len(prefix):]
|
||||||
}
|
}
|
||||||
item := protocol.CompletionItem{
|
item := protocol.CompletionItem{
|
||||||
Label: candidate.Label,
|
Label: candidate.Label,
|
||||||
Detail: candidate.Detail,
|
Detail: candidate.Detail,
|
||||||
Kind: toProtocolCompletionItemKind(candidate.Kind),
|
Kind: toProtocolCompletionItemKind(candidate.Kind),
|
||||||
InsertTextFormat: protocol.PlainTextTextFormat,
|
|
||||||
TextEdit: &protocol.TextEdit{
|
TextEdit: &protocol.TextEdit{
|
||||||
NewText: insertText,
|
NewText: insertText,
|
||||||
Range: protocol.Range{
|
Range: protocol.Range{
|
||||||
@ -44,8 +46,6 @@ func toProtocolCompletionItems(candidates []source.CompletionItem, prefix string
|
|||||||
End: pos,
|
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
|
// 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
|
// according to their score. This can be removed upon the resolution of
|
||||||
// https://github.com/Microsoft/language-server-protocol/issues/348.
|
// https://github.com/Microsoft/language-server-protocol/issues/348.
|
||||||
|
Loading…
Reference in New Issue
Block a user