summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2018-03-30 00:01:03 +0200
committerChristoph Schlosser <christophschlosser@users.noreply.github.com>2018-03-30 00:09:58 +0200
commit45175bbc91fb48f05724b0fec773e309f3e976f3 (patch)
treec92e646ff942b2361f709cadfda51ff1b148c1c5
parent301cd45289f58b32819b217c34c49e7e09104afb (diff)
downloaddoxdocgen-45175bbc91fb48f05724b0fec773e309f3e976f3.tar.gz
Don’t trigger comment generation while in comment
-rw-r--r--src/CodeParserController.ts19
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;