File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -420,8 +420,7 @@ module Fsi =
420420 let! profile =
421421 match provider.provideTerminalProfile ( ctok) with
422422 | None -> promise.Return None
423- | Some( U2.Case1 options) -> promise.Return( Some options)
424- | Some( U2.Case2 work) -> Promise.ofThenable work
423+ | Some work -> work |> Promise.ofMaybeThenable Some
425424
426425 let profile =
427426 match profile with
@@ -431,10 +430,7 @@ module Fsi =
431430
432431 failwith " unable to spawn FSI"
433432
434- let terminal =
435- match profile.options with
436- | U2.Case1 opts -> window.createTerminal opts
437- | U2.Case2 opts -> window.createTerminal opts
433+ let terminal = window.createTerminal !! profile.options
438434
439435 // Wait for the new terminal to be ready
440436 let! newTerminal =
Original file line number Diff line number Diff line change @@ -442,8 +442,10 @@ module SolutionExplorer =
442442 ti.id <-
443443 let label ( ti : TreeItem ) =
444444 match ti.label with
445- | Some( U2.Case1 l) -> l
446- | Some( U2.Case2 l) -> l.label
445+ | Some( l) ->
446+ match box l with
447+ | :? string as l -> l
448+ | l -> ( l :?> TreeItemLabel) .label
447449 | None -> " "
448450
449451 match element with
Original file line number Diff line number Diff line change @@ -284,6 +284,14 @@ module Promise =
284284 let ofThenable ( t : Thenable < 't >) : JS.Promise < 't > = unbox ( box t)
285285 let toThenable ( p : JS.Promise < 't >) : Thenable < 't > = unbox ( box p)
286286
287+ [<Emit( " typeof ($0 || {}).then === 'function'" ) >]
288+ let isThenable ( x : obj ) : bool = jsNative
289+
290+ let ofMaybeThenable ( ifValue : 'T1 -> 'T2 ) ( t : U2 < 'T1 , Thenable < 'T2 >>) : JS.Promise < 'T2 > =
291+ match box t with
292+ | t when isThenable t -> unbox t |> ofThenable
293+ | t -> unbox t |> ifValue |> Promise.lift
294+
287295 let onSuccess = Promise.tap
288296
289297 // source: https://github.com/ionide/ionide-vscode-helpers/blob/5e4c28c79ed565497cd481fac2f22ee2d8d28406/src/Helpers.fs#L92
You can’t perform that action at this time.
0 commit comments