diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index a0f8a810ccb..4b66db0d4fd 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -1520,9 +1520,15 @@ module ParsedInput = None) | _ -> None) - member _.VisitEnumDefn(_, _, _) = - // No completions anywhere in an enum, except in attributes, which is established earlier in VisitAttributeApplication - Some CompletionContext.Invalid + member _.VisitEnumDefn(_, cases, _) = + cases + |> List.tryPick (fun (SynEnumCase(ident = SynIdent (ident = id))) -> + if rangeContainsPos id.idRange pos then + // No completions in an enum case identifier + Some CompletionContext.Invalid + else + // The value expression should still get completions + None) member _.VisitTypeAbbrev(_, _, range) = if rangeContainsPos range pos then diff --git a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs index eab0a63997a..85eee176393 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs @@ -1281,11 +1281,15 @@ type A = l let ``No completion on enum case identifier at declaration site`` () = let fileContents = """ +let [] lit = 1 + type A = | C = 0 + | D = l """ VerifyNoCompletionList(fileContents, "| C") + VerifyCompletionList(fileContents, "| D = l", [ "lit" ], []) [] let ``Completion list in generic function body contains type parameter`` () =