Skip to content

Commit e63e709

Browse files
committed
Fix initialization
1 parent 6130119 commit e63e709

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

src/PowerShellEditorServices/Server/PsesServiceCollectionExtensions.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ public static IServiceCollection AddPsesLanguageServices(
2626
this IServiceCollection collection,
2727
HostStartupInfo hostStartupInfo)
2828
{
29-
return collection.AddSingleton<WorkspaceService>()
29+
return collection
30+
.AddSingleton<HostStartupInfo>(hostStartupInfo)
31+
.AddSingleton<WorkspaceService>()
3032
.AddSingleton<SymbolsService>()
31-
.AddSingleton<EditorServicesConsolePSHost>(
32-
(provider) => EditorServicesConsolePSHost.Create(
33-
provider.GetService<ILoggerFactory>(),
34-
provider.GetService<ILanguageServer>(),
35-
hostStartupInfo))
33+
.AddSingleton<EditorServicesConsolePSHost>()
3634
.AddSingleton<IRunspaceContext>(
3735
(provider) => provider.GetService<EditorServicesConsolePSHost>())
3836
.AddSingleton<PowerShellExecutionService>(
@@ -43,16 +41,16 @@ public static IServiceCollection AddPsesLanguageServices(
4341
.AddSingleton<TemplateService>()
4442
.AddSingleton<EditorOperationsService>()
4543
.AddSingleton<RemoteFileManagerService>()
46-
.AddSingleton(
47-
(provider) =>
44+
.AddSingleton(async (provider) =>
4845
{
4946
var extensionService = new ExtensionService(
5047
provider.GetService<PowerShellExecutionService>(),
51-
provider.GetService<OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer>());
52-
extensionService.InitializeAsync(
48+
provider.GetService<ILanguageServer>());
49+
50+
await extensionService.InitializeAsync(
5351
serviceProvider: provider,
54-
editorOperations: provider.GetService<EditorOperationsService>())
55-
.Wait();
52+
editorOperations: provider.GetService<EditorOperationsService>()).ConfigureAwait(false);
53+
5654
return extensionService;
5755
})
5856
.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)