diff --git a/gopls/internal/lsp/cache/snapshot.go b/gopls/internal/lsp/cache/snapshot.go index 7e0a9ba196b..bff3dc17f63 100644 --- a/gopls/internal/lsp/cache/snapshot.go +++ b/gopls/internal/lsp/cache/snapshot.go @@ -1605,9 +1605,6 @@ func (s *snapshot) reloadOrphanedOpenFiles(ctx context.Context) error { files = append(files, o) } } - if len(files) == 0 { - return nil - } // Filter to files that are not known to be unloadable. s.mu.Lock() @@ -1620,6 +1617,10 @@ func (s *snapshot) reloadOrphanedOpenFiles(ctx context.Context) error { files = loadable s.mu.Unlock() + if len(files) == 0 { + return nil + } + var uris []span.URI for _, file := range files { uris = append(uris, file.URI())