diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go index 45667031d1..d0e6841f38 100644 --- a/internal/lsp/source/hover.go +++ b/internal/lsp/source/hover.go @@ -45,9 +45,13 @@ func (i *IdentifierInfo) Hover(ctx context.Context, markdownSupported bool, hove return "", err } var b strings.Builder - if comment := formatDocumentation(h.comment, hoverKind); comment != "" { - b.WriteString(comment) - b.WriteRune('\n') + + // Add documentation to the top if the HoverKind is anything other than full documentation. + if hoverKind != FullDocumentation { + if comment := formatDocumentation(h.comment, hoverKind); comment != "" { + b.WriteString(comment) + b.WriteRune('\n') + } } if markdownSupported { b.WriteString("```go\n") @@ -63,6 +67,13 @@ func (i *IdentifierInfo) Hover(ctx context.Context, markdownSupported bool, hove if markdownSupported { b.WriteString("\n```") } + // Add documentation to the bottom if the HoverKind is full documentation. + if hoverKind == FullDocumentation { + if comment := formatDocumentation(h.comment, hoverKind); comment != "" { + b.WriteRune('\n') + b.WriteString(comment) + } + } return b.String(), nil }