Skip to content

Commit 33aa62c

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> (cherry picked from commit 571a207) Reviewed-on: https://go-review.googlesource.com/c/tools/+/254217
1 parent e585dae commit 33aa62c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/lsp/source/workspace_symbol.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"golang.org/x/tools/internal/event"
1717
"golang.org/x/tools/internal/lsp/fuzzy"
1818
"golang.org/x/tools/internal/lsp/protocol"
19+
"golang.org/x/tools/internal/span"
1920
)
2021

2122
// 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
278279
}
279280
// Make sure we only walk files once (we might see them more than once due to
280281
// build constraints).
281-
seen := make(map[*ast.File]bool)
282+
seen := make(map[span.URI]bool)
282283
for _, pv := range toWalk {
283284
sc.current = pv
284285
for _, pgf := range pv.pkg.CompiledGoFiles() {
285-
if seen[pgf.File] {
286+
if seen[pgf.URI] {
286287
continue
287288
}
289+
seen[pgf.URI] = true
288290
sc.curFile = pgf
289291
sc.walkFilesDecls(pgf.File.Decls)
290292
}

0 commit comments

Comments
 (0)