Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/Compiler/Facilities/RichText.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ module RichText =
let ofParts (parts: TaggedText[]) =
if Array.isEmpty parts then empty else RichText(parts)

let ofTaggedText (part: TaggedText) = RichText([| part |])
let ofTaggedText (part: TaggedText) =
if String.IsNullOrEmpty part.Text then
empty
else
RichText([| part |])

let ofTag tag (text: string) =
if String.IsNullOrEmpty text then
Expand Down
9 changes: 7 additions & 2 deletions src/Compiler/Facilities/TextLayoutRender.fs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,17 @@ module LayoutRender =
member _.Start() = NoState

member _.AddText z text =
collector text
if not (String.IsNullOrEmpty text.Text) then
collector text

z

member _.AddBreak rstrs n =
collector TaggedText.lineBreak
collector (TaggedText.tagSpace (spaces n))

if n > 0 then
collector (TaggedText.tagSpace (spaces n))

rstrs

member _.AddTag z (_, _, _) = z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ module RichTextTests =
(RichText.mkMethod "").IsEmpty |> shouldBeTrue
(RichText.ofTag TextTag.Class "").IsEmpty |> shouldBeTrue

[<Fact>]
let ``Empty tagged text gives empty text`` () =
(RichText.ofTaggedText (tagged TextTag.Class "")).IsEmpty |> shouldBeTrue

[<Fact>]
let ``Empty layout gives empty text`` () =
(LayoutRender.toRichText emptyL).IsEmpty |> shouldBeTrue

[<Fact>]
let ``Rendering a layout skips parts with no text`` () =
let layout =
(leftL (tagged TextTag.Text "") ^^ wordL (TaggedText.tagClass "Foo"))
@@ wordL (TaggedText.tagText "bar")

LayoutRender.toRichText layout
|> assertRichTextParts [ TextTag.Class, "Foo"; TextTag.LineBreak, "\n"; TextTag.Text, "bar" ]

[<Fact>]
let ``Parts are dumped as tag and text pairs`` () =
RichText.ofParts
Expand Down
14 changes: 14 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/TooltipTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,3 +1195,17 @@ let _ = List.m{caret}ap id [1]
"""
Assert.Contains("List.map", remarks)
Assert.DoesNotContain("ListModule", remarks)

[<Fact>]
let ``Parameter tooltip has empty remarks`` () =
let (ToolTipText items) =
Checker.getTooltip """
module TestNs
let bar a{caret} b = a - b
"""
match items with
| [ ToolTipElement.Group [ element ] ] ->
match element.Remarks with
| Some remarks -> Assert.True(remarks.IsEmpty, $"Expected empty remarks, got parts: %A{remarks.Parts}")
| None -> ()
| _ -> failwith $"Expected a single group, got {items}"
Loading