aboutsummaryrefslogtreecommitdiff
path: root/internal/lsp/references.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/lsp/references.go')
-rw-r--r--internal/lsp/references.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/internal/lsp/references.go b/internal/lsp/references.go
index 28d658716..ea238d4a3 100644
--- a/internal/lsp/references.go
+++ b/internal/lsp/references.go
@@ -57,17 +57,22 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam
// it is added to the beginning of the list if IncludeDeclaration
// was specified.
if params.Context.IncludeDeclaration {
- rng, err := ident.Declaration.Range()
+ decSpan, err := ident.Declaration.Span()
if err != nil {
return nil, err
}
- locations = append([]protocol.Location{
- {
- URI: protocol.NewURI(ident.Declaration.URI()),
- Range: rng,
- },
- }, locations...)
-
+ if !seen[decSpan] {
+ rng, err := ident.Declaration.Range()
+ if err != nil {
+ return nil, err
+ }
+ locations = append([]protocol.Location{
+ {
+ URI: protocol.NewURI(ident.Declaration.URI()),
+ Range: rng,
+ },
+ }, locations...)
+ }
}
return locations, nil
}