Skip to content

Commit 955bcba

Browse files
committed
Fix missing project load notifications
1 parent 0eeb218 commit 955bcba

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

src/FsAutoComplete/LspServers/AdaptiveServerState.fs

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,43 @@ type AdaptiveState
379379

380380
let notifications = Event<NotificationEvent * CancellationToken>()
381381

382+
do
383+
workspaceLoader.Notifications.Subscribe(fun n ->
384+
let inline trigger n = notifications.Trigger(n, CancellationToken.None)
385+
386+
match n with
387+
| Ionide.ProjInfo.Types.WorkspaceProjectState.Loading(p) -> ProjectResponse.ProjectLoading(p)
388+
| Ionide.ProjInfo.Types.WorkspaceProjectState.Loaded(p, _knownProjs, cache) ->
389+
390+
let projViewerItemsNormalized = ProjectViewer.render p
391+
392+
let responseFiles =
393+
projViewerItemsNormalized.Items
394+
|> List.map (function
395+
| ProjectViewerItem.Compile(p, c) -> ProjectViewerItem.Compile(Helpers.fullPathNormalized p, c))
396+
|> List.choose (function
397+
| ProjectViewerItem.Compile(p, _) -> Some p)
398+
399+
let references = FscArguments.references (p.OtherOptions)
400+
401+
let ws =
402+
{ ProjectFileName = p.ProjectFileName
403+
ProjectFiles = responseFiles
404+
OutFileOpt = Option.ofObj p.TargetPath
405+
References = references
406+
Extra = p
407+
ProjectItems = projViewerItemsNormalized.Items
408+
Additionals = Map.empty }
409+
410+
ProjectResponse.Project(ws, cache)
411+
412+
| Ionide.ProjInfo.Types.WorkspaceProjectState.Failed(p, e) -> ProjectResponse.ProjectError(p, e)
413+
|> NotificationEvent.Workspace
414+
|> trigger
415+
416+
)
417+
|> disposables.Add
418+
382419
let scriptFileProjectOptions = Event<CompilerProjectOption>()
383420

384421
let fileParsed =
@@ -1001,34 +1038,12 @@ type AdaptiveState
10011038
>> Log.addContextDestructured "path" ((|BaseIntermediateOutputPath|_|) p.Properties)
10021039
)
10031040

1004-
let projectFileName = p.ProjectFileName
1005-
let projViewerItemsNormalized = ProjectViewer.render p
1006-
1007-
let responseFiles =
1008-
projViewerItemsNormalized.Items
1009-
|> List.map (function
1010-
| ProjectViewerItem.Compile(p, c) -> ProjectViewerItem.Compile(Helpers.fullPathNormalized p, c))
1011-
|> List.choose (function
1012-
| ProjectViewerItem.Compile(p, _) -> Some p)
1013-
1014-
let references = FscArguments.references (p.OtherOptions)
1015-
10161041
logger.info (
10171042
Log.setMessage "ProjectLoaded {file}"
1018-
>> Log.addContextDestructured "file" projectFileName
1043+
>> Log.addContextDestructured "file" p.ProjectFileName
10191044
)
10201045

1021-
let ws =
1022-
{ ProjectFileName = projectFileName
1023-
ProjectFiles = responseFiles
1024-
OutFileOpt = Option.ofObj p.TargetPath
1025-
References = references
1026-
Extra = p
1027-
ProjectItems = projViewerItemsNormalized.Items
1028-
Additionals = Map.empty }
10291046

1030-
let not = ProjectResponse.Project(ws, false) |> NotificationEvent.Workspace
1031-
notifications.Trigger(not, CancellationToken.None)
10321047

10331048
let not = ProjectResponse.WorkspaceLoad true |> NotificationEvent.Workspace
10341049

0 commit comments

Comments
 (0)