diff options
| -rw-r--r-- | src/CodeParserController.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/CodeParserController.ts b/src/CodeParserController.ts index 6dfc263..04928e8 100644 --- a/src/CodeParserController.ts +++ b/src/CodeParserController.ts @@ -70,6 +70,11 @@ export default class CodeParserController { return false; } + // Check if currently in a comment block + if (this.inComment(activeEditor, activeSelection.line)) { + return false; + } + // Do not trigger when there's whitespace after the trigger sequence // tslint:disable-next-line:max-line-length const seq = "[\\s]*(" + this.cfg.C.triggerSequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + ")$"; @@ -83,6 +88,20 @@ export default class CodeParserController { } } + private inComment(activeEditor: TextEditor, activeLine: number): boolean { + if (activeLine === 0) { + return false; + } + + const txt: string = activeEditor.document.lineAt(activeLine - 1).text.trim(); + if (!txt.startsWith("///") && !txt.startsWith("*") && + !txt.startsWith("/**") && !txt.startsWith("/*!")) { + return false; + } else { + return true; + } + } + private onEvent(activeEditor: TextEditor, event: TextDocumentContentChangeEvent) { if (!this.check(activeEditor, event)) { return null; |