Skip to content

Commit 7ae7a11

Browse files
CopilotTheAngryByrd
andcommitted
Fix Find All References for Active Pattern Cases by filtering to specific case
Co-authored-by: TheAngryByrd <[email protected]>
1 parent db75f8e commit 7ae7a11

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/FsAutoComplete.Core/Commands.fs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -780,10 +780,21 @@ module Commands =
780780
let symbolUses = tyRes.GetCheckResults.GetUsesOfSymbolInFile(symbol, ct)
781781

782782
let symbolUses: _ seq =
783-
if includeDeclarations then
784-
symbolUses
785-
else
786-
symbolUses |> Seq.filter (fun u -> not u.IsFromDefinition)
783+
let filtered =
784+
if includeDeclarations then
785+
symbolUses
786+
else
787+
symbolUses |> Seq.filter (fun u -> not u.IsFromDefinition)
788+
789+
// For Active Pattern Cases, FCS returns all cases in the pattern, not just the specific one
790+
// We need to filter to only the symbol that matches our query
791+
match symbolUse.Symbol with
792+
| :? FSharpActivePatternCase as apc ->
793+
filtered |> Seq.filter (fun u ->
794+
match u.Symbol with
795+
| :? FSharpActivePatternCase as foundApc -> foundApc.Name = apc.Name
796+
| _ -> false)
797+
| _ -> filtered
787798

788799
let ranges = symbolUses |> Seq.map (fun u -> u.Range)
789800
// Note: tryAdjustRanges is designed to only be able to fail iff `errorOnFailureToFixRange` is `true`

0 commit comments

Comments
 (0)