mirror of https://github.com/golang/go.git
internal/lsp: fix bad completion for variadic functions
Add variadic completion in functions only if snippets is enabled. Fixes golang/go#42691 Change-Id: I0aebe86b5a58d2f7491f0b340ad14b15c184eeb1 GitHub-Last-Rev: 04b2ad0d1eb5be80fdb34bfaf3fc6eda0362f3f2 GitHub-Pull-Request: golang/tools#280 Reviewed-on: https://go-review.googlesource.com/c/tools/+/295950 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Rebecca Stambler <rstambler@golang.org> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
7ee29554cc
commit
bcb2d7b23b
|
|
@ -95,6 +95,7 @@ type completionOptions struct {
|
|||
fullDocumentation bool
|
||||
placeholders bool
|
||||
literal bool
|
||||
snippets bool
|
||||
matcher source.Matcher
|
||||
budget time.Duration
|
||||
}
|
||||
|
|
@ -519,6 +520,7 @@ func Completion(ctx context.Context, snapshot source.Snapshot, fh source.FileHan
|
|||
placeholders: opts.UsePlaceholders,
|
||||
literal: opts.LiteralCompletions && opts.InsertTextFormat == protocol.SnippetTextFormat,
|
||||
budget: opts.CompletionBudget,
|
||||
snippets: opts.InsertTextFormat == protocol.SnippetTextFormat,
|
||||
},
|
||||
// default to a matcher that always matches
|
||||
matcher: prefixMatcher(""),
|
||||
|
|
|
|||
|
|
@ -150,9 +150,8 @@ func (c *completer) item(ctx context.Context, cand candidate) (CompletionItem, e
|
|||
prefix = typeName + "(" + prefix
|
||||
suffix = ")"
|
||||
}
|
||||
|
||||
// Add variadic "..." if we are filling in a variadic param.
|
||||
if cand.variadic {
|
||||
// Add variadic "..." only if snippets if enabled or cand is not a function
|
||||
if cand.variadic && (c.opts.snippets || !cand.expandFuncCall) {
|
||||
suffix += "..."
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue