Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692))
* Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764))
* Disallow using base to invoke an abstract base method. ([Issue #13926](https://github.com/dotnet/fsharp/issues/13926), [PR #16773](https://github.com/dotnet/fsharp/pull/16773))
* Fix broken code completion after a record type declaration ([PR #16813]([Title](https://github.com/dotnet/fsharp/pull/16813)))

### Added

Expand Down
8 changes: 6 additions & 2 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,7 @@ module ParsedInput =
| SynType.LongIdent _ when rangeContainsPos ty.Range pos -> Some CompletionContext.Type
| _ -> defaultTraverse ty

member _.VisitRecordDefn(_, fields, _) =
member _.VisitRecordDefn(_, fields, range) =
fields
|> List.tryPick (fun (SynField(idOpt = idOpt; range = fieldRange)) ->
match idOpt with
Expand All @@ -1653,7 +1653,11 @@ module ParsedInput =
| _ when rangeContainsPos fieldRange pos -> Some(CompletionContext.RecordField(RecordContext.Declaration false))
| _ -> None)
// No completions in a record outside of all fields, except in attributes, which is established earlier in VisitAttributeApplication
|> Option.orElse (Some CompletionContext.Invalid)
|> Option.orElseWith (fun _ ->
if rangeContainsPos range pos then
Some CompletionContext.Invalid
else
None)

member _.VisitUnionDefn(_, cases, _) =
cases
Expand Down
9 changes: 9 additions & 0 deletions tests/service/CompletionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ let assertHasItemWithNames names (completionInfo: DeclarationListInfo) =
for name in names do
Assert.That(Set.contains name itemNames, $"{name} not found in {itemNames}")

[<Test>]
let ``Expr - After record decl`` () =
let info = getCompletionInfo "{ Fi }" (4, 0) """
type Record = { Field: int }


"""
assertHasItemWithNames ["ignore"] info

[<Test>]
let ``Expr - record - field 01 - anon module`` () =
let info = getCompletionInfo "{ Fi }" (4, 3) """
Expand Down