Skip to content

Commit 31a02a8

Browse files
Maxime MangelMaxime Mangel
andauthored
Support new type return by 'fsharp/documentation' and add support for "Open documentation" link from the tooltips (#1861)
Co-authored-by: Maxime Mangel <[email protected]>
1 parent 828844a commit 31a02a8

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

src/Components/InfoPanel.fs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module InfoPanel =
7474

7575
let mapContent res =
7676
if isNotNull res then
77-
let res: DocumentationDescription = (res.Data |> Array.concat).[0]
77+
let res: DocumentationDescription = res.Data
7878

7979
let fsharpBlock lines =
8080
let cnt = (lines |> String.concat "\n")
@@ -85,24 +85,15 @@ module InfoPanel =
8585
sprintf "<pre>\n%s\n</pre>" cnt
8686

8787
let sigContent =
88-
let lines =
89-
res.Signature
90-
|> String.split [| '\n' |]
91-
|> Array.filter (not << String.IsNullOrWhiteSpace)
92-
93-
match lines |> Array.splitAt (lines.Length - 1) with
94-
| (h, [| StartsWith "Full name:" fullName |]) ->
95-
[| yield fsharpBlock h; yield "*" + fullName + "*" |]
96-
| _ -> [| fsharpBlock lines |]
97-
|> String.concat "\n"
88+
res.Signature
89+
|> String.split [| '\n' |]
90+
|> Array.filter (not << String.IsNullOrWhiteSpace)
91+
|> fsharpBlock
9892

9993
let commentContent = res.Comment
10094

10195
let footerContent =
102-
res.Footer
103-
|> String.split [| '\n' |]
104-
|> Array.filter (not << String.IsNullOrWhiteSpace)
105-
|> Array.map (fun n -> "*" + n + "*")
96+
res.FooterLines
10697
|> String.concat "\n\n"
10798

10899
let ctors =
@@ -138,7 +129,7 @@ module InfoPanel =
138129
|> fsharpBlock
139130

140131
let types =
141-
res.Types
132+
res.DeclaredTypes
142133
|> List.filter (not << String.IsNullOrWhiteSpace)
143134
|> List.distinct
144135
|> fsharpBlock
@@ -271,8 +262,17 @@ module InfoPanel =
271262
| None -> openPanel () |> ignore
272263

273264
let private showDocumentation o =
274-
Panel.updateOnLink !!o?XmlDocSig !!o?AssemblyName
265+
// If the panel doesn't exist, open it
266+
// This happens when using click on "Open documentation" from inside
267+
// the tooltip
268+
promise {
269+
match Panel.panel with
270+
| Some _ -> ()
271+
| None ->
272+
do! openPanel ()
275273

274+
do! Panel.updateOnLink !!o?XmlDocSig !!o?AssemblyName
275+
}
276276

277277
let private selectionChanged (event: TextEditorSelectionChangeEvent) =
278278
let updateMode = "FSharp.infoPanelUpdate" |> Configuration.get "onCursorMove"

src/Core/DTO.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ module DTO =
6363
Functions: string list
6464
Interfaces: string list
6565
Attributes: string list
66-
Types: string list
66+
DeclaredTypes: string list
6767
Signature: string
6868
Comment: string
69-
Footer: string }
69+
FooterLines: string list }
7070

7171
type Error =
7272
{

src/Core/LanguageService.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Consider:
248248
Position = { Line = line; Character = col } }
249249

250250
cl.sendRequest ("fsharp/documentation", req)
251-
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription[][]>>
251+
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription>>
252252

253253
let documentationForSymbol xmlSig assembly =
254254
match client with
@@ -259,7 +259,7 @@ Consider:
259259
XmlSig = xmlSig }
260260

261261
cl.sendRequest ("fsharp/documentationSymbol", req)
262-
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription[][]>>
262+
|> Promise.map checkNotificationAndCast<Result<DocumentationDescription>>
263263

264264
let signature (uri: Uri) line col =
265265
match client with
@@ -614,7 +614,10 @@ Consider:
614614
opts.revealOutputChannelOn <- Some Client.RevealOutputChannelOn.Never
615615

616616
opts.initializationOptions <- Some !^(Some initOpts)
617-
opts?markdown <- createObj [ "isTrusted" ==> true ]
617+
opts?markdown <- createObj [
618+
"isTrusted" ==> true
619+
"supportHtml" ==> true
620+
]
618621

619622
opts
620623

0 commit comments

Comments
 (0)