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
2 changes: 1 addition & 1 deletion src/Compiler/Service/FSharpCheckerResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -889,14 +889,14 @@ type internal TypeCheckInfo
match minfos with
| [] -> CompletionItemKind.Method false
| minfo :: _ -> CompletionItemKind.Method minfo.IsExtensionMember
| Item.AnonRecdField _
| Item.RecdField _
| Item.Property _ -> CompletionItemKind.Property
| Item.Event _ -> CompletionItemKind.Event
| Item.ILField _
| Item.Value _ -> CompletionItemKind.Field
| Item.CustomOperation _ -> CompletionItemKind.CustomOperation
// These items are not given a completion kind. This could be reviewed
| Item.AnonRecdField _
| Item.ActivePatternResult _
| Item.CustomOperation _
| Item.CtorGroup _
Expand Down
17 changes: 1 addition & 16 deletions tests/service/CompletionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ let assertHasItemWithNames names (completionInfo: DeclarationListInfo) =
for name in names do
Assert.That(Set.contains name itemNames, name)

let assertHasExactlyNamesAndNothingElse names (completionInfo: DeclarationListInfo) =
let itemNames = getCompletionItemNames completionInfo |> set
let expectedNames = Set.ofList names

Assert.That(itemNames, Is.EqualTo expectedNames)


[<Test>]
let ``Expr - record - field 01 - anon module`` () =
let info = getCompletionInfo "{ Fi }" (4, 3) """
Expand Down Expand Up @@ -62,12 +55,4 @@ let record = { Field = 1 }
{ }
"""
assertHasItemWithNames ["Field"; "record"] info

[<Test>]
let ``Expr - array of anonymous records`` () =
let info = getCompletionInfo "x[0]." (3, 6) """
let x = [ {| Name = "foo" |} ]
x[0].
"""
assertHasExactlyNamesAndNothingElse ["Name"; "Equals"; "GetHashCode"; "GetType"; "ToString"] info
assertHasItemWithNames ["Field"; "record"] info
Original file line number Diff line number Diff line change
Expand Up @@ -1450,3 +1450,13 @@ let t2 (x: {| D: NestdRecTy; E: {| a: string |} |}) = {| x with E.a = "a"; D.B =
"let t2 (x: {| D: NestdRecTy; E: {| a: string |} |}) = {| x with E.a = \"a\"; D.",
[ "B"; "C" ]
)

[<Fact>]
let ``Anonymous record fields have higher priority than methods`` () =
let fileContents =
"""
let x = [ {| Goo = 1; Foo = "foo" |} ]
x[0].
"""

VerifyCompletionListExactly(fileContents, "x[0].", [ "Foo"; "Goo"; "Equals"; "GetHashCode"; "GetType"; "ToString" ])