Skip to content

Commit cae0faf

Browse files
authored
Merge pull request #3191 from obsidian-tasks-group/fix-on-completion-parsing
fix: - Allow multiple spaces after onCompletion emoji
2 parents 2c27987 + 6f40279 commit cae0faf

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/TaskSerializer/DefaultTaskSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const DEFAULT_SYMBOLS: DefaultTaskSerializerSymbols = {
9191
doneDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
9292
cancelledDateRegex: / *(\d{4}-\d{2}-\d{2})$/u,
9393
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu,
94-
onCompletionRegex: /🏁 ?([a-zA-Z]+)$/iu,
94+
onCompletionRegex: /🏁 *([a-zA-Z]+)$/iu,
9595
dependsOnRegex: new RegExp('⛔\uFE0F? *(' + taskIdSequenceRegex.source + ')$', 'iu'),
9696
idRegex: new RegExp('🆔 *(' + taskIdRegex.source + ')$', 'iu'),
9797
},

tests/TaskSerializer/DefaultTaskSerializer.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('validate emoji regular expressions', () => {
7171
doneDateRegex: /✅ *(\\d{4}-\\d{2}-\\d{2})$/u
7272
cancelledDateRegex: /❌ *(\\d{4}-\\d{2}-\\d{2})$/u
7373
recurrenceRegex: /🔁 ?([a-zA-Z0-9, !]+)$/iu
74-
onCompletionRegex: /🏁 ?([a-zA-Z]+)$/iu
74+
onCompletionRegex: /🏁 *([a-zA-Z]+)$/iu
7575
dependsOnRegex: /⛔️? *([a-zA-Z0-9-_]+( *, *[a-zA-Z0-9-_]+ *)*)$/iu
7676
idRegex: /🆔 *([a-zA-Z0-9-_]+)$/iu"
7777
`);
@@ -170,10 +170,16 @@ describe.each(symbolMap)("DefaultTaskSerializer with '$taskFormat' symbols", ({
170170

171171
describe('should parse onCompletion', () => {
172172
it('should parse delete action', () => {
173-
const onCompletion = `${onCompletionSymbol} delete`;
173+
const onCompletion = `${onCompletionSymbol} Delete`;
174174
const taskDetails = deserialize(onCompletion);
175175
expect(taskDetails).toMatchTaskDetails({ onCompletion: OnCompletion.Delete });
176176
});
177+
178+
it('should allow multiple spaces', () => {
179+
const onCompletion = `${onCompletionSymbol} Keep`;
180+
const taskDetails = deserialize(onCompletion);
181+
expect(taskDetails).toMatchTaskDetails({ onCompletion: OnCompletion.Keep });
182+
});
177183
});
178184

179185
describe('should parse depends on', () => {

0 commit comments

Comments
 (0)