diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index d582a7084..ba9d13271 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1379,6 +1379,12 @@ protected async Task HandleDocumentFormattingRequest( DocumentFormattingParams formattingParams, RequestContext requestContext) { + if (this.editorSession.AnalysisService == null) + { + await requestContext.SendError("Script analysis is not enabled in this session"); + return; + } + var result = await Format( formattingParams.TextDocument.Uri, formattingParams.options, @@ -1398,6 +1404,12 @@ protected async Task HandleDocumentRangeFormattingRequest( DocumentRangeFormattingParams formattingParams, RequestContext requestContext) { + if (this.editorSession.AnalysisService == null) + { + await requestContext.SendError("Script analysis is not enabled in this session"); + return; + } + var result = await Format( formattingParams.TextDocument.Uri, formattingParams.Options,