From 301cd45289f58b32819b217c34c49e7e09104afb Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Tue, 27 Mar 2018 23:42:12 +0200 Subject: =?UTF-8?q?Don=E2=80=99t=20trigger=20if=20there=E2=80=99s=20whites?= =?UTF-8?q?pace=20after=20sequence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CodeParserController.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/CodeParserController.ts') diff --git a/src/CodeParserController.ts b/src/CodeParserController.ts index 1084c46..6dfc263 100644 --- a/src/CodeParserController.ts +++ b/src/CodeParserController.ts @@ -70,9 +70,17 @@ export default class CodeParserController { return false; } - const cont: string = activeLine.text.trim(); + // 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, "\\$&") + ")$"; + const match: RegExpMatchArray = activeLine.text.match(seq); - return this.cfg.C.triggerSequence === cont; + if (match !== null) { + const cont: string = match[1]; + return this.cfg.C.triggerSequence === cont; + } else { + return false; + } } private onEvent(activeEditor: TextEditor, event: TextDocumentContentChangeEvent) { -- cgit v1.2.3