Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltips: unify rendering #534

Draft
wants to merge 1 commit into
base: net232
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,28 @@ type FSharpQuickDocPresenter(xmlDocService: FSharpXmlDocService, identifier: IFS
(RichText.Empty, text.GetFormattedParts()) ||> Seq.fold (fun result part ->
result.Append(part.Text.Replace("<", "&lt;").Replace(">", "&gt;").Replace("\n", "<br>"), part.Style))

let asContent (text: RichText) =
"<div class='content'>" + richTextEscapeToHtml text + "</div>"
let asContent text =
RichText("<div class='content'>", TextStyle.Default)
.Append(richTextEscapeToHtml text)
.Append("</div>", TextStyle.Default)

//todo: move all the html related code to the platform
let asDefinition (text: RichText) =
"<div class='definition'><pre style='word-wrap: break-word; white-space: pre-wrap;'>" +
richTextEscapeToHtml text +
"</pre></div>"

let createToolTip (header: RichText) (body: RichText) =
if body.IsEmpty then
asContent header
else
(asDefinition header).Append(body)
let asDefinition text =
RichText("<div class='definition'><pre>", TextStyle.Default)
.Append(richTextEscapeToHtml text)
.Append("</pre></div>", TextStyle.Default)

let createToolTipLayout header (body: RichText) =
(asDefinition header).Append(body)

let createTooltip (text: RichText) =
RichText("<html>
<head>
<style>pre {word-wrap: break-word; white-space: pre-wrap;}</style>
</head>
<body>")
.Append(text)
.Append("</body></html>")

member x.CreateRichTextTooltip() =
FSharpQuickDoc.getFSharpToolTipText identifier
Expand Down Expand Up @@ -85,9 +93,10 @@ type FSharpQuickDocPresenter(xmlDocService: FSharpXmlDocService, identifier: IFS
| _ -> () ]
|> richTextJoin "\n\n"

createToolTip header body))
|> richTextJoin IdentifierTooltipProvider.RIDER_TOOLTIP_SEPARATOR
createToolTipLayout header body))
|> richTextJoin ""
)
|> Option.map createTooltip
|> Option.defaultValue null

interface IQuickDocPresenter with
Expand Down