Skip to content

Commit b131422

Browse files
authored
Fix a bug in parameter name hints (#15156)
1 parent 9c3f562 commit b131422

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type InlineParameterNameHints(parseResults: FSharpParseFileResults) =
123123
let curryRanges = getCurryRanges symbolUse
124124

125125
let ranges =
126-
if Seq.isEmpty tupleRanges then
126+
if symbol.IsFunction || Seq.isEmpty tupleRanges then
127127
curryRanges |> List.toSeq
128128
else
129129
tupleRanges

vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace FSharp.Editor.Tests.Hints
44

55
open Xunit
66
open HintTestFramework
7+
open FSharp.Test
78

89
module InlineParameterNameHintTests =
910

@@ -599,3 +600,42 @@ None
599600
let actual = getParameterNameHints document
600601

601602
Assert.Equal(expected, actual)
603+
604+
[<Fact>]
605+
let ``Hints are shown correctly in type constructors mixed with functions`` () =
606+
let code =
607+
"""
608+
type X = | X of a: int list * b: string
609+
610+
let x = X(List.map id [ 42 ], "")
611+
"""
612+
613+
let document = getFsDocument code
614+
615+
let expected =
616+
[
617+
{
618+
Content = "a = "
619+
Location = (3, 11)
620+
Tooltip = "field a"
621+
}
622+
{
623+
Content = "mapping = "
624+
Location = (3, 20)
625+
Tooltip = "parameter mapping"
626+
}
627+
{
628+
Content = "list = "
629+
Location = (3, 23)
630+
Tooltip = "parameter list"
631+
}
632+
{
633+
Content = "b = "
634+
Location = (3, 31)
635+
Tooltip = "field b"
636+
}
637+
]
638+
639+
let actual = getParameterNameHints document
640+
641+
actual |> Assert.shouldBeEquivalentTo expected

0 commit comments

Comments
 (0)