mirror of https://github.com/golang/go.git
internal/lsp/diagnostics: avoid erroneous error message for orphaned files
If the user changes the extension of a go file while editing, the existing code complains 'No packages found for open file'. This error messsag is not helpful and this CL avoids it. Change-Id: Idf426f1ce8b83b23757f81aa1f322fea86df9d82 Reviewed-on: https://go-review.googlesource.com/c/tools/+/350789 Run-TryBot: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Peter Weinberger <pjw@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
7559231edc
commit
a0016a2ade
|
|
@ -439,6 +439,10 @@ func (s *Server) checkForOrphanedFile(ctx context.Context, snapshot source.Snaps
|
|||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
// If the file no longer has a name ending in .go, this diagnostic is wrong
|
||||
if filepath.Ext(fh.URI().Filename()) != ".go" {
|
||||
return nil
|
||||
}
|
||||
// TODO(rstambler): We should be able to parse the build tags in the
|
||||
// file and show a more specific error message. For now, put the diagnostic
|
||||
// on the package declaration.
|
||||
|
|
|
|||
Loading…
Reference in New Issue