mirror of
https://github.com/golang/go
synced 2024-11-18 03:04:45 -07:00
internal/lsp/source: fix duplicates in workspaceSymbols
The logic to de-dupe workspace symbols was broken in two ways: - The 'seen' map of files already processed was never written. - The key to 'seen' was *ast.File, which doesn't work if we parse twice. Fix this by de-duping instead on span.URI. Change-Id: Iedadfac17a0a993570ff4f8301a97815477f1c2c Reviewed-on: https://go-review.googlesource.com/c/tools/+/254117 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
53e29e9d12
commit
571a207697
@ -16,6 +16,7 @@ import (
|
||||
"golang.org/x/tools/internal/event"
|
||||
"golang.org/x/tools/internal/lsp/fuzzy"
|
||||
"golang.org/x/tools/internal/lsp/protocol"
|
||||
"golang.org/x/tools/internal/span"
|
||||
)
|
||||
|
||||
// maxSymbols defines the maximum number of symbol results that should ever be
|
||||
@ -278,13 +279,14 @@ func (sc *symbolCollector) walk(ctx context.Context, views []View) (_ []protocol
|
||||
}
|
||||
// Make sure we only walk files once (we might see them more than once due to
|
||||
// build constraints).
|
||||
seen := make(map[*ast.File]bool)
|
||||
seen := make(map[span.URI]bool)
|
||||
for _, pv := range toWalk {
|
||||
sc.current = pv
|
||||
for _, pgf := range pv.pkg.CompiledGoFiles() {
|
||||
if seen[pgf.File] {
|
||||
if seen[pgf.URI] {
|
||||
continue
|
||||
}
|
||||
seen[pgf.URI] = true
|
||||
sc.curFile = pgf
|
||||
sc.walkFilesDecls(pgf.File.Decls)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user