Skip to content

Commit

Permalink
fix: Fix wrong references number
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tao <[email protected]>
  • Loading branch information
tcx4c70 committed Mar 27, 2024
1 parent 4b57c5f commit b38c8ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/Handlers/CodeLens.fs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ module CodeLens =
| None -> return p |> success
| Some symbol ->
let! refs = wm.FindReferences symbol
// FIXME: refNum is wrong. There are lots of false positive even if we distinct locations by
// (l.Location.SourceTree.FilePath, l.Location.SourceSpan)
let refNum = refs |> Seq.map (fun r -> r.Locations |> Seq.length) |> Seq.fold (+) 0
let refNum =
refs
|> Seq.collect (fun r -> r.Locations)
|> Seq.distinctBy (fun l -> (l.Location.SourceTree.FilePath, l.Location.SourceSpan))
|> Seq.length
let title = sprintf "%d Reference(s)" refNum

let arg: ReferenceParams =
Expand Down
2 changes: 1 addition & 1 deletion src/Handlers/References.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ module References =
| None -> return None |> success
| Some symbol ->
let! refs = wm.FindReferences symbol
// FIXME: refs is wrong. There are lots of false positive even if we add Seq.distinct before Seq.toArray
return
refs
|> Seq.collect (fun r -> r.Locations)
|> Seq.map (fun rl -> Location.fromRoslynLocation rl.Location)
|> Seq.distinct
|> Seq.toArray
|> Some
|> success
Expand Down

0 comments on commit b38c8ad

Please sign in to comment.