Skip to content

Commit

Permalink
Remove duplicate entries (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
5nord committed Dec 9, 2021
1 parent c1dda4a commit 2e4a473
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion internal/lsp/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *Server) definition(ctx context.Context, params *protocol.DefinitionPara
}
}

return locs, nil
return unifyLocs(locs), nil
}

func cTags(suite *ntt.Suite, file string, line int, col int) []protocol.Location {
Expand Down Expand Up @@ -70,3 +70,16 @@ func cTags(suite *ntt.Suite, file string, line int, col int) []protocol.Location
}
return ret
}

func unifyLocs(locs []protocol.Location) []protocol.Location {
m := make(map[protocol.Location]bool)
for _, loc := range locs {
m[loc] = true
}

ret := make([]protocol.Location, len(m))
for loc := range m {
ret = append(ret, loc)
}
return ret
}
2 changes: 1 addition & 1 deletion internal/lsp/references.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam
elapsed := time.Since(start)
log.Debug(fmt.Sprintf("References took %s. IdentifierInfo: %#v", elapsed, id.String()))
}
return locs, nil
return unifyLocs(locs), nil
}

0 comments on commit 2e4a473

Please sign in to comment.