Skip to content

Commit 95d2e58

Browse files
committed
internal/lsp/source: use logical filenames for workspace symbols
We need to use the filename derived from the symbol information, not the one from CompiledGoFiles, in case of cgo packages. No tests because workspace symbols are entangled with document symbols, and the latter doesn't work in cgo packages. Fixes golang/go#37659. Change-Id: Ic32293c542830a49b37c25ebf3b231771c3a4225 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222060 Run-TryBot: Heschi Kreinick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]>
1 parent d6a4d55 commit 95d2e58

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/lsp/source/workspace_symbol.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,21 @@ outer:
4747
return nil, err
4848
}
4949
for _, si := range findSymbol(file.Decls, pkg.GetTypesInfo(), matcher) {
50-
rng, err := nodeToProtocolRange(view, pkg, si.node)
50+
mrng, err := posToMappedRange(view, pkg, si.node.Pos(), si.node.End())
5151
if err != nil {
52-
log.Error(ctx, "Error getting range for node", err)
52+
log.Error(ctx, "Error getting mapped range for node", err)
53+
continue
54+
}
55+
rng, err := mrng.Range()
56+
if err != nil {
57+
log.Error(ctx, "Error getting range from mapped range", err)
5358
continue
5459
}
5560
symbols = append(symbols, protocol.SymbolInformation{
5661
Name: si.name,
5762
Kind: si.kind,
5863
Location: protocol.Location{
59-
URI: protocol.URIFromSpanURI(fh.File().Identity().URI),
64+
URI: protocol.URIFromSpanURI(mrng.URI()),
6065
Range: rng,
6166
},
6267
})

0 commit comments

Comments
 (0)