diff --git a/src/features/HelpCompletion.ts b/src/features/HelpCompletion.ts index 368acc91b1..940b1c0803 100644 --- a/src/features/HelpCompletion.ts +++ b/src/features/HelpCompletion.ts @@ -6,6 +6,7 @@ import { Disposable, EndOfLine, Position, Range, SnippetString, TextDocument, TextDocumentChangeEvent, window, workspace } from "vscode"; import { LanguageClient, RequestType } from "vscode-languageclient"; import { IFeature } from "../feature"; +import { Logger } from "../logging"; export const CommentHelpRequestType = new RequestType("powerShell/getCommentHelp"); @@ -27,7 +28,7 @@ export class HelpCompletionFeature implements IFeature { private languageClient: LanguageClient; private disposable: Disposable; - constructor() { + constructor(private log: Logger) { this.helpCompletionProvider = new HelpCompletionProvider(); const subscriptions = []; workspace.onDidChangeTextDocument(this.onEvent, this, subscriptions); @@ -44,7 +45,8 @@ export class HelpCompletionFeature implements IFeature { } public onEvent(changeEvent: TextDocumentChangeEvent): void { - if (!changeEvent) { + if (!(changeEvent && changeEvent.contentChanges && changeEvent.contentChanges[0])) { + this.log.write(`Bad change event message: ${JSON.stringify(changeEvent)}`); return; } diff --git a/src/main.ts b/src/main.ts index eb27fd56cf..169235db8b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -124,7 +124,7 @@ export function activate(context: vscode.ExtensionContext): void { new DebugSessionFeature(context, sessionManager), new PickPSHostProcessFeature(), new SpecifyScriptArgsFeature(context), - new HelpCompletionFeature(), + new HelpCompletionFeature(logger), new CustomViewsFeature(), ];