From c425a3eef00e922483bf24358d7c98abc226978c Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 16 May 2016 11:17:58 -0700 Subject: [PATCH] Fix #221: Occasional init hang in LanguageServer This change fixes an issue in the LanguageServer where the length of time that it takes to evaluate the extension API script can cause the "initialize" request to not complete. This leaves the VS Code language server client in an initializing state where no language features will work for the rest of the session. The fix is to execute the extension API script after the "initialize" handler has been registered. --- .../Server/LanguageServer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index ecc285097..1cd5065c5 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -74,11 +74,6 @@ public LanguageServer(HostDetails hostDetails, ChannelBase serverChannel) protected override void Initialize() { - // Initialize the extension service - // TODO: This should be made awaited once Initialize is async! - this.editorSession.ExtensionService.Initialize( - this.editorOperations).Wait(); - // Register all supported message types this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest); @@ -107,6 +102,11 @@ protected override void Initialize() this.SetRequestHandler(InvokeExtensionCommandRequest.Type, this.HandleInvokeExtensionCommandRequest); this.SetRequestHandler(DebugAdapterMessages.EvaluateRequest.Type, this.HandleEvaluateRequest); + + // Initialize the extension service + // TODO: This should be made awaited once Initialize is async! + this.editorSession.ExtensionService.Initialize( + this.editorOperations).Wait(); } protected override async Task Shutdown()