mirror of
https://github.com/golang/go
synced 2024-11-18 17:04:41 -07:00
internal/lsp: change ordering of hover depending on hoverKind
This change configures the ordering of documentation on hover. If the user has requested full documentation, the signature appears at the top, to avoid the user having to scroll. Otherwise, the signature appears at the bottom, to minimize the distance between the triggering identifier and the signature. Updates golang/go#33352 Change-Id: I017baaabd0ee0c31cb13cb6abdda296782929823 Reviewed-on: https://go-review.googlesource.com/c/tools/+/189943 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
4147ede4f8
commit
0d62d4405e
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user