Skip to content

Commit 192ac77

Browse files
adonovangopherbot
authored andcommittedJan 3, 2025·
internal/golang: CodeAction: don't return empty source.doc titles
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 <[email protected]> Reviewed-by: Robert Findley <[email protected]> Commit-Queue: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 5fe60fd commit 192ac77

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

Diff for: ‎gopls/internal/golang/codeaction.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,10 @@ func goplsDocFeatures(ctx context.Context, req *codeActionsRequest) error {
442442
// See [server.commandHandler.Doc] for command implementation.
443443
func goDoc(ctx context.Context, req *codeActionsRequest) error {
444444
_, _, title := DocFragment(req.pkg, req.pgf, req.start, req.end)
445-
cmd := command.NewDocCommand(title, command.DocArgs{Location: req.loc, ShowDocument: true})
446-
req.addCommandAction(cmd, false)
445+
if title != "" {
446+
cmd := command.NewDocCommand(title, command.DocArgs{Location: req.loc, ShowDocument: true})
447+
req.addCommandAction(cmd, false)
448+
}
447449
return nil
448450
}
449451

0 commit comments

Comments
 (0)
Please sign in to comment.