diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs index 9f00ac7fa..0432fa2ee 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs @@ -1162,7 +1162,15 @@ protected async Task HandleCommentHelpRequest( CommentHelpRequestParams requestParams, RequestContext requestContext) { - ScriptFile scriptFile = this.editorSession.Workspace.GetFile(requestParams.DocumentUri); + var result = new CommentHelpRequestResult(); + + ScriptFile scriptFile; + if (!this.editorSession.Workspace.TryGetFile(requestParams.DocumentUri, out scriptFile)) + { + await requestContext.SendResult(result); + return; + } + int triggerLine = requestParams.TriggerPosition.Line + 1; string helpLocation; @@ -1171,8 +1179,6 @@ protected async Task HandleCommentHelpRequest( triggerLine, out helpLocation); - var result = new CommentHelpRequestResult(); - if (functionDefinitionAst == null) { await requestContext.SendResult(result);