Skip to content

Commit

Permalink
gopls/internal/lsp/cache: check number of orphaned files after filtering
Browse files Browse the repository at this point in the history
I noticed redundant "reloadOrphanedFiles reloading" logs in
https://storage.googleapis.com/go-build-log/0b9348fc/openbsd-amd64-72_04342286.log

This is because we were checking for no reloadable files before
filtering out unloadable files, not after. Fix this logic error.

Change-Id: Ib7ad122bb7f96fdf53474c329fac1ec8ec0e1ef3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/499755
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr committed May 31, 2023
1 parent a260315 commit 98f1b4d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions gopls/internal/lsp/cache/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand Down

0 comments on commit 98f1b4d

Please sign in to comment.