Skip to content

Commit

Permalink
Defend against crash when no PSSA (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Holt authored and TylerLeonhardt committed Jun 25, 2019
1 parent 2434761 commit 5f9d89a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,12 @@ protected async Task HandleDocumentFormattingRequestAsync(
DocumentFormattingParams formattingParams,
RequestContext<TextEdit[]> requestContext)
{
if (this.editorSession.AnalysisService == null)
{
await requestContext.SendErrorAsync("Script analysis is not enabled in this session");
return;
}

var result = await FormatAsync(
formattingParams.TextDocument.Uri,
formattingParams.options,
Expand All @@ -1399,6 +1405,12 @@ protected async Task HandleDocumentRangeFormattingRequestAsync(
DocumentRangeFormattingParams formattingParams,
RequestContext<TextEdit[]> requestContext)
{
if (this.editorSession.AnalysisService == null)
{
await requestContext.SendErrorAsync("Script analysis is not enabled in this session");
return;
}

var result = await FormatAsync(
formattingParams.TextDocument.Uri,
formattingParams.Options,
Expand Down

0 comments on commit 5f9d89a

Please sign in to comment.