@@ -107,6 +107,7 @@ module Project =
107
107
108
108
sln.Items |> Array.collect getProjs |> Array.toList
109
109
| Some( WorkspacePeekFound.Directory dir) -> dir.Fsprojs |> Array.toList
110
+ | Some( WorkspacePeekFound.Fsproj fsproj) -> [ fsproj.Fsproj ]
110
111
111
112
112
113
let getNotLoaded () =
@@ -251,6 +252,7 @@ module Project =
251
252
match loadedWorkspace with
252
253
| None -> Array.empty
253
254
| Some( WorkspacePeekFound.Directory dir) -> dir.Fsprojs
255
+ | Some( WorkspacePeekFound.Fsproj fsproj) -> [| fsproj.Fsproj |]
254
256
| Some( WorkspacePeekFound.Solution sln) -> sln.Items |> Array.collect foldFsproj |> Array.map fst
255
257
256
258
let loadingInProgress p =
@@ -308,6 +310,7 @@ module Project =
308
310
type ConfiguredWorkspace =
309
311
| Solution of path : string
310
312
| Directory of path : string
313
+ | Fsproj of path : string
311
314
312
315
module private CurrentWorkspaceConfiguration =
313
316
let private key = " FSharp.workspacePath"
@@ -322,6 +325,8 @@ module Project =
322
325
323
326
if value.ToLowerInvariant() .EndsWith( " .sln" ) then
324
327
ConfiguredWorkspace.Solution fullPath
328
+ else if value.ToLowerInvariant() .EndsWith( " .fsproj" ) then
329
+ ConfiguredWorkspace.Fsproj fullPath
325
330
else
326
331
ConfiguredWorkspace.Directory fullPath
327
332
@@ -333,6 +338,12 @@ module Project =
333
338
not ( isNull stats) && ( stats.isDirectory ())
334
339
with _ ->
335
340
false
341
+ | ConfiguredWorkspace.Fsproj fsproj ->
342
+ try
343
+ let stats = node.fs.statSync ( U2.Case1 fsproj)
344
+ not ( isNull stats) && ( stats.isFile ())
345
+ with _ ->
346
+ false
336
347
| ConfiguredWorkspace.Solution sln ->
337
348
try
338
349
let stats = node.fs.statSync ( U2.Case1 sln)
@@ -373,6 +384,7 @@ module Project =
373
384
match value with
374
385
| ConfiguredWorkspace.Solution path -> path
375
386
| ConfiguredWorkspace.Directory path -> path
387
+ | ConfiguredWorkspace.Fsproj path -> path
376
388
377
389
let private isConfiguredInWorkspace () =
378
390
match getStringFromWorkspaceConfig () with
@@ -400,6 +412,7 @@ module Project =
400
412
let setFromPeek ( value : WorkspacePeekFound ) =
401
413
match value with
402
414
| WorkspacePeekFound.Directory dir -> ConfiguredWorkspace.Directory dir.Directory
415
+ | WorkspacePeekFound.Fsproj fsproj -> ConfiguredWorkspace.Fsproj fsproj.Fsproj
403
416
| WorkspacePeekFound.Solution sln -> ConfiguredWorkspace.Solution sln.Path
404
417
|> set
405
418
@@ -419,6 +432,7 @@ module Project =
419
432
| ConfiguredWorkspace.Directory valueDir, WorkspacePeekFound.Directory peekDir ->
420
433
removeEndSlash valueDir = removeEndSlash peekDir.Directory
421
434
| ConfiguredWorkspace.Solution valueSln, WorkspacePeekFound.Solution peekSln -> valueSln = peekSln.Path
435
+ | ConfiguredWorkspace.Fsproj valueFsproj, WorkspacePeekFound.Fsproj peekFsproj -> valueFsproj = peekFsproj.Fsproj
422
436
| _ -> false
423
437
424
438
let tryFind ( value : ConfiguredWorkspace option ) ( found : WorkspacePeekFound list ) =
@@ -444,6 +458,12 @@ module Project =
444
458
item.label <- sprintf " %s%s " check dir.Directory
445
459
item.description <- Some( sprintf " Directory with %i projects" dir.Fsprojs.Length)
446
460
item
461
+ | WorkspacePeekFound.Fsproj fsproj ->
462
+ let relative = node.path.relative ( workspace.rootPath.Value, fsproj.Fsproj)
463
+ let item = createEmpty< QuickPickItem>
464
+ item.label <- sprintf " %s%s " check relative
465
+ item.description <- Some( sprintf " Single project" )
466
+ item
447
467
| WorkspacePeekFound.Solution sln ->
448
468
let relative = node.path.relative ( workspace.rootPath.Value, sln.Path)
449
469
let item = createEmpty< QuickPickItem>
@@ -556,12 +576,12 @@ module Project =
556
576
return []
557
577
else
558
578
let! ws = LanguageService.workspacePeek workspace.rootPath.Value deepLevel ( excluded |> List.ofArray)
559
-
560
579
return
561
580
ws.Found
562
581
|> Array.sortBy ( fun x ->
563
582
match x with
564
583
| WorkspacePeekFound.Solution sln -> countProjectsInSln sln
584
+ | WorkspacePeekFound.Fsproj _ -> 0
565
585
| WorkspacePeekFound.Directory _ -> - 1 )
566
586
|> Array.rev
567
587
|> List.ofArray
@@ -572,33 +592,39 @@ module Project =
572
592
let! ws = workspacePeek ()
573
593
let configured = CurrentWorkspaceConfiguration.get ()
574
594
let configuredPeek = CurrentWorkspaceConfiguration.tryFind configured ws
575
-
576
- match configuredPeek with
577
- | Some peek ->
578
- // If a workspace is configured, use it
579
- return Some peek
580
- | None ->
595
+ let! choosen = pickFSACWorkspace ws None
596
+ return choosen
597
+
598
+ // TODO: Rewrite this so that the sln isn't always chosen, maybe add a config?
599
+
600
+ // match configuredPeek with
601
+ // | Some peek ->
602
+ // // If a workspace is configured, use it
603
+ // return Some peek
604
+ // | None ->
605
+
581
606
// prefer the sln, load directly the first one, otherwise ask
582
- let slns =
583
- ws
584
- |> List.choose ( fun x ->
585
- match x with
586
- | WorkspacePeekFound.Solution _ -> Some x
587
- | _ -> None)
588
-
589
- let! choosen =
590
- match slns with
591
- | [] ->
592
- ws
593
- |> List.tryPick ( fun x ->
594
- match x with
595
- | WorkspacePeekFound.Directory _ -> Some x
596
- | _ -> None)
597
- |> Promise.lift
598
- | [ sln ] -> Promise.lift ( Some sln)
599
- | _ -> pickFSACWorkspace ws None
600
-
601
- return choosen
607
+ // let slns =
608
+ // ws
609
+ // |> List.choose (fun x ->
610
+ // match x with
611
+ // | WorkspacePeekFound.Solution _ -> Some x
612
+ // | _ -> None)
613
+
614
+ // let! choosen =
615
+ // match slns with
616
+ // | [] ->
617
+ // ws
618
+ // |> List.tryPick (fun x ->
619
+ // match x with
620
+ // | WorkspacePeekFound.Directory _ -> Some x
621
+ // | _ -> None)
622
+ // |> Promise.lift
623
+ // | [ sln ] -> Promise.lift (Some sln)
624
+ // | _ -> pickFSACWorkspace ws None
625
+
626
+ // let! choosen = pickFSACWorkspace ws None
627
+ // return choosen
602
628
}
603
629
604
630
let handleProjectParsedNotification res =
@@ -650,10 +676,12 @@ module Project =
650
676
let projs =
651
677
match x with
652
678
| WorkspacePeekFound.Directory dir -> dir.Fsprojs
679
+ | WorkspacePeekFound.Fsproj fsproj -> [| fsproj.Fsproj |]
653
680
| WorkspacePeekFound.Solution sln -> sln.Items |> Array.collect foldFsproj |> Array.map fst
654
681
655
682
match x with
656
683
| WorkspacePeekFound.Solution _ -> setAnyProjectContext true
684
+ | WorkspacePeekFound.Fsproj _ -> setAnyProjectContext false
657
685
| WorkspacePeekFound.Directory _ when not ( projs |> Array.isEmpty) -> setAnyProjectContext true
658
686
| _ -> ()
659
687
0 commit comments