1
0
mirror of https://github.com/golang/go synced 2024-11-18 12:54:44 -07:00

internal/lsp: don't offer empty "Organize Imports" action

If there are no imports that need organizing, don't send the "Organize
Imports" code action.

Change-Id: Id01521edd1524fb3f7372fd787d6c90418740cf3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/202825
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Muir Manders 2019-10-23 12:07:22 -07:00 committed by Rebecca Stambler
parent 98e333b8b3
commit c8fcd6ab79

View File

@ -102,7 +102,7 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
}
}
}
if wanted[protocol.SourceOrganizeImports] {
if wanted[protocol.SourceOrganizeImports] && len(edits) > 0 {
codeActions = append(codeActions, protocol.CodeAction{
Title: "Organize Imports",
Kind: protocol.SourceOrganizeImports,