Skip to content

Commit 5f9d89a

Browse files
Robert HoltTylerLeonhardt
Robert Holt
authored andcommitted
Defend against crash when no PSSA (#974)
1 parent 2434761 commit 5f9d89a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

+12
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,12 @@ protected async Task HandleDocumentFormattingRequestAsync(
13801380
DocumentFormattingParams formattingParams,
13811381
RequestContext<TextEdit[]> requestContext)
13821382
{
1383+
if (this.editorSession.AnalysisService == null)
1384+
{
1385+
await requestContext.SendErrorAsync("Script analysis is not enabled in this session");
1386+
return;
1387+
}
1388+
13831389
var result = await FormatAsync(
13841390
formattingParams.TextDocument.Uri,
13851391
formattingParams.options,
@@ -1399,6 +1405,12 @@ protected async Task HandleDocumentRangeFormattingRequestAsync(
13991405
DocumentRangeFormattingParams formattingParams,
14001406
RequestContext<TextEdit[]> requestContext)
14011407
{
1408+
if (this.editorSession.AnalysisService == null)
1409+
{
1410+
await requestContext.SendErrorAsync("Script analysis is not enabled in this session");
1411+
return;
1412+
}
1413+
14021414
var result = await FormatAsync(
14031415
formattingParams.TextDocument.Uri,
14041416
formattingParams.Options,

0 commit comments

Comments
 (0)