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>
diff --git a/internal/lsp/code_action.go b/internal/lsp/code_action.go
index dadb9e8..9afe69d 100644
--- a/internal/lsp/code_action.go
+++ b/internal/lsp/code_action.go
@@ -102,7 +102,7 @@
}
}
}
- if wanted[protocol.SourceOrganizeImports] {
+ if wanted[protocol.SourceOrganizeImports] && len(edits) > 0 {
codeActions = append(codeActions, protocol.CodeAction{
Title: "Organize Imports",
Kind: protocol.SourceOrganizeImports,