Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -21,6 +21,7 @@
* Parser: fix pattern range for idents with trivia ([PR #16824](https://github.com/dotnet/fsharp/pull/16824))
* Fix broken code completion after a record type declaration ([PR #16813](https://github.com/dotnet/fsharp/pull/16813))
* Enforce AttributeTargets on enums ([PR #16887](https://github.com/dotnet/fsharp/pull/16887))
* Completion: fix for unfinished record field decl ([PR #16893](https://github.com/dotnet/fsharp/pull/16893))

### Added

Expand Down
7 changes: 4 additions & 3 deletions src/Compiler/Service/ServiceParsedInputOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,11 +1646,12 @@ module ParsedInput =

member _.VisitRecordDefn(_, fields, range) =
fields
|> List.tryPick (fun (SynField(idOpt = idOpt; range = fieldRange)) ->
match idOpt with
| Some id when rangeContainsPos id.idRange pos ->
|> List.tryPick (fun (SynField(idOpt = idOpt; range = fieldRange; fieldType = fieldType)) ->
match idOpt, fieldType with
| Some id, _ when rangeContainsPos id.idRange pos ->
Some(CompletionContext.RecordField(RecordContext.Declaration true))
| _ when rangeContainsPos fieldRange pos -> Some(CompletionContext.RecordField(RecordContext.Declaration false))
| _, SynType.FromParseError _ -> 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.orElseWith (fun _ ->
Expand Down
9 changes: 8 additions & 1 deletion tests/service/CompletionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ let ``Underscore dot lambda - method completion`` () =
let myFancyFunc (x:string) =
x
|> _.ToL"""
assertHasItemWithNames ["ToLower"] info
assertHasItemWithNames ["ToLower"] info

[<Test>]
let ``Type decl - Record - Field type 01`` () =
let info = getCompletionInfo "type Record = { Field: }" (2, 23) """
type Record = { Field: }
"""
assertHasItemWithNames ["string"] info