internal/lsp: improve error message about unsaved files
We should mention which files gopls thinks are unsaved.
Change-Id: I291976ad9bbf52e27c84fae650c613eb7ece8e83
Reviewed-on: https://go-review.googlesource.com/c/tools/+/340469
Trust: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/lsp/command.go b/internal/lsp/command.go
index d810735..61c794b 100644
--- a/internal/lsp/command.go
+++ b/internal/lsp/command.go
@@ -73,11 +73,15 @@
func (c *commandHandler) run(ctx context.Context, cfg commandConfig, run commandFunc) (err error) {
if cfg.requireSave {
+ var unsaved []string
for _, overlay := range c.s.session.Overlays() {
if !overlay.Saved() {
- return errors.New("All files must be saved first")
+ unsaved = append(unsaved, overlay.URI().Filename())
}
}
+ if len(unsaved) > 0 {
+ return errors.Errorf("All files must be saved first (unsaved: %v).", unsaved)
+ }
}
var deps commandDeps
if cfg.forURI != "" {