mirror of
https://github.com/golang/go
synced 2024-11-18 18:44:42 -07:00
internal/lsp: do not format the file on import organization
Updates golang/go#30843 Updates golang/go#35114 Change-Id: Id3f66d20b1ada9e53298b2370214b23b87bb0680 Reviewed-on: https://go-review.googlesource.com/c/tools/+/204557 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
d229a6140f
commit
075a17623f
9
internal/lsp/cache/session.go
vendored
9
internal/lsp/cache/session.go
vendored
@ -18,7 +18,6 @@ import (
|
||||
"golang.org/x/tools/internal/lsp/source"
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/span"
|
||||
"golang.org/x/tools/internal/telemetry/log"
|
||||
"golang.org/x/tools/internal/telemetry/trace"
|
||||
"golang.org/x/tools/internal/xcontext"
|
||||
errors "golang.org/x/xerrors"
|
||||
@ -320,15 +319,13 @@ func (s *session) openOverlay(ctx context.Context, uri span.URI, kind source.Fil
|
||||
hash: hashContents(data),
|
||||
unchanged: true,
|
||||
}
|
||||
_, hash, err := s.cache.GetFile(uri, kind).Read(ctx)
|
||||
if err != nil {
|
||||
log.Error(ctx, "failed to read", err, telemetry.File)
|
||||
return
|
||||
}
|
||||
// If the file is on disk, check if its content is the same as the overlay.
|
||||
if _, hash, err := s.cache.GetFile(uri, kind).Read(ctx); err == nil {
|
||||
if hash == s.overlays[uri].hash {
|
||||
s.overlays[uri].sameContentOnDisk = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *session) readOverlay(uri span.URI) *overlay {
|
||||
s.overlayMu.Lock()
|
||||
|
@ -197,6 +197,10 @@ func AllImportsFixes(ctx context.Context, view View, f File) (edits []protocol.T
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Do not change the file if there are no import fixes.
|
||||
if len(fixes) == 0 {
|
||||
return nil
|
||||
}
|
||||
// Apply all of the import fixes to the file.
|
||||
formatted, err := imports.ApplyFixes(fixes, f.URI().Filename(), data, options)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user