Skip to content

Commit

Permalink
internal/golang: CodeAction: don't return empty source.doc titles
Browse files Browse the repository at this point in the history
The source.doc code action was observed to produce empty command
titles on occasion; it should not offer a command in that case.

(A test doesn't make much sense because it would assert that a
particular input doesn't produce a command, whereas the invariant
that matters is that empty command titles are never shown.)

Change-Id: Ibe5de418954d299ea0d7809c35e7496ff353be6f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/639836
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
adonovan authored and gopherbot committed Jan 3, 2025
1 parent 5fe60fd commit 192ac77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions gopls/internal/golang/codeaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,10 @@ func goplsDocFeatures(ctx context.Context, req *codeActionsRequest) error {
// See [server.commandHandler.Doc] for command implementation.
func goDoc(ctx context.Context, req *codeActionsRequest) error {
_, _, title := DocFragment(req.pkg, req.pgf, req.start, req.end)
cmd := command.NewDocCommand(title, command.DocArgs{Location: req.loc, ShowDocument: true})
req.addCommandAction(cmd, false)
if title != "" {
cmd := command.NewDocCommand(title, command.DocArgs{Location: req.loc, ShowDocument: true})
req.addCommandAction(cmd, false)
}
return nil
}

Expand Down

0 comments on commit 192ac77

Please sign in to comment.