From d8d5ae78aba2fa9f73ff122c7e59463e9175cde2 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Thu, 15 Oct 2020 15:51:52 +0200 Subject: [PATCH] fix(shortSyntax): "asd #asd" case --- src/app/features/tasks/short-syntax.spec.ts | 18 ++++++++++++++++++ src/app/features/tasks/short-syntax.util.ts | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/features/tasks/short-syntax.spec.ts b/src/app/features/tasks/short-syntax.spec.ts index 8229ce5fae..6557d8c230 100644 --- a/src/app/features/tasks/short-syntax.spec.ts +++ b/src/app/features/tasks/short-syntax.spec.ts @@ -185,6 +185,24 @@ describe('shortSyntax', () => { }); }); + it('should add new "asd #asd" tag', () => { + const t = { + ...TASK, + title: 'asd #asd', + tagIds: [] + }; + const r = shortSyntax(t, ALL_TAGS); + + expect(r).toEqual({ + newTagTitles: ['asd'], + remindAt: null, + projectId: undefined, + taskChanges: { + title: 'asd', + } + }); + }); + it('should not add tags for sub tasks', () => { const t = { ...TASK, diff --git a/src/app/features/tasks/short-syntax.util.ts b/src/app/features/tasks/short-syntax.util.ts index 6943aa8bea..cfe5372b99 100644 --- a/src/app/features/tasks/short-syntax.util.ts +++ b/src/app/features/tasks/short-syntax.util.ts @@ -126,7 +126,8 @@ const parseTagChanges = (task: Partial, allTags?: Tag[]): { taskChange .map(title => title.trim().replace(CH_TAG, '')) .filter(newTagTitle => newTagTitle.length >= 1 - && initialTitle.trim().indexOf(newTagTitle) > 4 + // NOTE: we check this to not trigger for "#123 blasfs dfasdf" + && initialTitle.trim().lastIndexOf(newTagTitle) > 4 ); const tagIdsToAdd: string[] = [];