Skip to content

Commit 4a978d4

Browse files
committed
Fix initialization
1 parent 7db0012 commit 4a978d4

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

src/PowerShellEditorServices/Server/PsesServiceCollectionExtensions.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ public static IServiceCollection AddPsesLanguageServices(
2424
this IServiceCollection collection,
2525
HostStartupInfo hostStartupInfo)
2626
{
27-
return collection.AddSingleton<WorkspaceService>()
27+
return collection
28+
.AddSingleton<HostStartupInfo>(hostStartupInfo)
29+
.AddSingleton<WorkspaceService>()
2830
.AddSingleton<SymbolsService>()
29-
.AddSingleton<EditorServicesConsolePSHost>(
30-
(provider) => EditorServicesConsolePSHost.Create(
31-
provider.GetService<ILoggerFactory>(),
32-
provider.GetService<ILanguageServer>(),
33-
hostStartupInfo))
31+
.AddSingleton<EditorServicesConsolePSHost>()
3432
.AddSingleton<IRunspaceContext>(
3533
(provider) => provider.GetService<EditorServicesConsolePSHost>())
3634
.AddSingleton<PowerShellExecutionService>(
@@ -41,16 +39,15 @@ public static IServiceCollection AddPsesLanguageServices(
4139
.AddSingleton<TemplateService>()
4240
.AddSingleton<EditorOperationsService>()
4341
.AddSingleton<RemoteFileManagerService>()
44-
.AddSingleton(
45-
(provider) =>
42+
.AddSingleton(async (provider) =>
4643
{
4744
var extensionService = new ExtensionService(
4845
provider.GetService<PowerShellExecutionService>(),
4946
provider.GetService<OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServerFacade>());
50-
extensionService.InitializeAsync(
47+
await extensionService.InitializeAsync(
5148
serviceProvider: provider,
52-
editorOperations: provider.GetService<EditorOperationsService>())
53-
.Wait();
49+
editorOperations: provider.GetService<EditorOperationsService>()).ConfigureAwait(false);
50+
5451
return extensionService;
5552
})
5653
.AddSingleton<AnalysisService>();

src/PowerShellEditorServices/Services/PowerShell/Execution/PipelineThreadExecutor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public IDisposable TakeTaskWriterLock()
106106

107107
private void Run()
108108
{
109+
_psesHost.PushInitialPowerShell();
109110
RunTopLevelConsumerLoop();
110111
}
111112

src/PowerShellEditorServices/Services/PowerShell/Host/EditorServicesConsolePSHost.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Host
2222

2323
internal class EditorServicesConsolePSHost : PSHost, IHostSupportsInteractiveSession, IRunspaceContext
2424
{
25-
public static EditorServicesConsolePSHost Create(
26-
ILoggerFactory loggerFactory,
27-
ILanguageServer languageServer,
28-
HostStartupInfo hostInfo)
29-
{
30-
var host = new EditorServicesConsolePSHost(loggerFactory, languageServer, hostInfo);
31-
host.PushInitialPowerShell();
32-
return host;
33-
}
34-
3525
private readonly ILogger _logger;
3626

3727
private readonly Stack<PowerShellContextFrame> _psFrameStack;
@@ -145,7 +135,7 @@ public override void SetShouldExit(int exitCode)
145135
SetExit();
146136
}
147137

148-
private void PushInitialPowerShell()
138+
public void PushInitialPowerShell()
149139
{
150140
SMA.PowerShell pwsh = _psFactory.CreateInitialPowerShell(_hostInfo, _readLineProvider);
151141
var runspaceInfo = RunspaceInfo.CreateFromLocalPowerShell(_logger, pwsh);

0 commit comments

Comments
 (0)