Skip to content

Commit

Permalink
Fix duplicate find references results (#15728)
Browse files Browse the repository at this point in the history
  • Loading branch information
0101 committed Aug 2, 2023
1 parent 6dd6899 commit 9513424
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions vsintegration/src/FSharp.Editor/Navigation/FindUsagesService.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ type internal FSharpFindUsagesService [<ImportingConstructor>] () =
}
|> liftAsync

let declarationSpans =
declarationSpans
|> List.distinctBy (fun x -> x.Document.FilePath, x.Document.Project.FilePath)

let isExternal = declarationSpans |> List.isEmpty

let displayParts =
Expand All @@ -98,7 +102,7 @@ type internal FSharpFindUsagesService [<ImportingConstructor>] () =

let definitionItems =
declarationSpans
|> List.map (fun span -> FSharpDefinitionItem.Create(tags, displayParts, span), span.Document.Project.Id)
|> List.map (fun span -> FSharpDefinitionItem.Create(tags, displayParts, span), span.Document.Project.FilePath)

for definitionItem, _ in definitionItems do
do! context.OnDefinitionFoundAsync(definitionItem) |> Async.AwaitTask |> liftAsync
Expand All @@ -123,8 +127,8 @@ type internal FSharpFindUsagesService [<ImportingConstructor>] () =
externalDefinitionItem
else
definitionItems
|> List.tryFind (fun (_, projectId) -> doc.Project.Id = projectId)
|> Option.map (fun (definitionItem, _) -> definitionItem)
|> List.tryFind (snd >> (=) doc.Project.FilePath)
|> Option.map fst
|> Option.defaultValue externalDefinitionItem

let referenceItem =
Expand Down

0 comments on commit 9513424

Please sign in to comment.