1
0
mirror of https://github.com/golang/go synced 2024-11-18 10:54:40 -07:00

internal/lsp: use URI as key in gc optimization details map

Packages that have gc_details enabled is stored internally in a
map[span.URI]struct{}, but when toggling on/off via ExecuteCommand, the
scheme is lost. The mismatch lead to no diagnostics from gc_details.

This fix uses span.URIFromPath() to parse the file path, so that the
internal keys are found when diagnostics are calculated.

Change-Id: I53b4e869625251c366b12b570eb03212319d2770
Reviewed-on: https://go-review.googlesource.com/c/tools/+/245858
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Pontus Leitzler 2020-07-30 21:10:16 +02:00 committed by Heschi Kreinick
parent 644d416712
commit fe6bb45d21

View File

@ -150,7 +150,7 @@ func (s *Server) executeCommand(ctx context.Context, params *protocol.ExecuteCom
if err := source.UnmarshalArgs(params.Arguments, &fileURI); err != nil {
return nil, err
}
pkgDir := span.URI(path.Dir(fileURI.Filename()))
pkgDir := span.URIFromPath(path.Dir(fileURI.Filename()))
s.gcOptimizationDetailsMu.Lock()
if _, ok := s.gcOptimizatonDetails[pkgDir]; ok {
delete(s.gcOptimizatonDetails, pkgDir)