diff --git a/src/features/HelpCompletion.ts b/src/features/HelpCompletion.ts index d4bc5f0736..f2a5f14e51 100644 --- a/src/features/HelpCompletion.ts +++ b/src/features/HelpCompletion.ts @@ -81,7 +81,9 @@ class TriggerFinder { break; case SearchState.Locked: - if (changeText.length === 1 && changeText[0] === this.triggerCharacters[this.count] && document === this.document) { + if (document === this.document && + changeText.length === 1 && + changeText[0] === this.triggerCharacters[this.count]) { this.count++; if (this.count === this.triggerCharacters.length) { this.state = SearchState.Found; @@ -154,12 +156,7 @@ class HelpCompletionProvider { triggerPosition: triggerStartPos, blockComment: this.triggerFinderBlockComment.found }).then(result => { - if (result === undefined) { - return; - } - - let content = result.content; - if (content === undefined) { + if (result == null || result.content == null) { return; } @@ -169,7 +166,7 @@ class HelpCompletionProvider { // Trim the leading whitespace (used by the rule for indentation) as VSCode takes care of the indentation. // Trim the last empty line and join the strings. - let text = content.map(x => x.trimLeft()).slice(0, -1).join(this.getEOL(doc.eol)); + let text = result.content.map(x => x.trimLeft()).slice(0, -1).join(this.getEOL(doc.eol)); editor.insertSnippet(new SnippetString(text), replaceRange); }); }