From 0ac6790fc6d033f3e9848712c064be1a5abac657 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Mon, 27 Jan 2020 16:39:28 -0500 Subject: [PATCH] internal/lsp: only reload orphaned files that belong to the workspace We were reloading all known files, which resulted in modifications to user's go.mod files. Change-Id: I14e86af896d1e75f3fdaaa00b9af8d7fb1d1e9e5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/216542 Run-TryBot: Rebecca Stambler Reviewed-by: Heschi Kreinick TryBot-Result: Gobot Gobot --- internal/lsp/cache/snapshot.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index c8dc650b57..dffecb1424 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -616,14 +616,7 @@ func (s *snapshot) reloadOrphanedFiles(ctx context.Context) error { s.mu.Unlock() } for _, m := range m { - // If a package's files belong to this view, it is a workspace package - // and should be added to the set of workspace packages. - for _, uri := range m.compiledGoFiles { - if !contains(s.view.session.viewsOf(uri), s.view) { - continue - } - s.setWorkspacePackage(ctx, m) - } + s.setWorkspacePackage(ctx, m) } return nil } @@ -638,6 +631,11 @@ func (s *snapshot) orphanedFileScopes() []interface{} { if fh.Identity().Kind != source.Go { continue } + // If the URI doesn't belong to this view, then it's not in a workspace + // package and should not be reloaded directly. + if !contains(s.view.session.viewsOf(uri), s.view) { + continue + } // Don't reload metadata for files we've already deemed unloadable. if _, ok := s.unloadableFiles[uri]; ok { continue