From 256244171580ced85d318eef79d5bd59e6fb338b Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Thu, 15 Aug 2019 11:35:00 -0400 Subject: [PATCH] internal/lsp: propagate hoverKind to completion documentation Fixes golang/go#33653 Change-Id: Ia45e4f4b7377681619303a6d414d9b9de3143c01 Reviewed-on: https://go-review.googlesource.com/c/tools/+/190400 Run-TryBot: Rebecca Stambler Reviewed-by: Suzy Mueller TryBot-Result: Gobot Gobot --- internal/lsp/completion.go | 5 +++-- internal/lsp/source/completion.go | 5 +++-- internal/lsp/source/completion_format.go | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/lsp/completion.go b/internal/lsp/completion.go index 6304828c67..6df9778ca7 100644 --- a/internal/lsp/completion.go +++ b/internal/lsp/completion.go @@ -32,8 +32,9 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara return nil, err } candidates, surrounding, err := source.Completion(ctx, view, f, rng.Start, source.CompletionOptions{ - DeepComplete: s.useDeepCompletions, - WantDocumentaton: s.wantCompletionDocumentation, + DeepComplete: s.useDeepCompletions, + WantDocumentaton: s.wantCompletionDocumentation, + WantFullDocumentation: s.hoverKind == fullDocumentation, }) if err != nil { log.Print(ctx, "no completions found", tag.Of("At", rng), tag.Of("Failure", err)) diff --git a/internal/lsp/source/completion.go b/internal/lsp/source/completion.go index 3700c0bad2..8178f0498d 100644 --- a/internal/lsp/source/completion.go +++ b/internal/lsp/source/completion.go @@ -304,8 +304,9 @@ type candidate struct { } type CompletionOptions struct { - DeepComplete bool - WantDocumentaton bool + DeepComplete bool + WantDocumentaton bool + WantFullDocumentation bool } // Completion returns a list of possible candidates for completion, given a diff --git a/internal/lsp/source/completion_format.go b/internal/lsp/source/completion_format.go index f3465f251c..7cb4426c8d 100644 --- a/internal/lsp/source/completion_format.go +++ b/internal/lsp/source/completion_format.go @@ -137,6 +137,9 @@ func (c *completer) item(cand candidate) (CompletionItem, error) { goto Return } item.Documentation = hover.Synopsis + if c.opts.WantFullDocumentation { + item.Documentation = hover.FullDocumentation + } } Return: return item, nil