Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### Review fixes

- Preserved punctuation immediately before a completion or elapsed-time tag when reopening a task.
- Rejected invalid ISO calendar dates in time estimates instead of silently rolling them into another month.
- Ignored empty relative file links wrapped in punctuation or spelled with dot path segments, instead of linking to the Todo document's directory.
- Kept tag cleanup and hidden-tag labels working after an unmatched backtick, while preserving tags inside complete inline code spans.
Expand Down
6 changes: 5 additions & 1 deletion src/utils/todo-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,9 @@ export const removeTodoStatusTag = (text: string, pattern: RegExp): string => {

if (!match) return text;

return text.slice(0, match.index) + text.slice(match.index + match[0].length);
// The tag-boundary regex includes the character before @. Keep punctuation,
// but consume the separating whitespace as before.
const boundary = match[0][0];
const prefix = boundary !== '@' && !/\s/.test(boundary) ? boundary : '';
return text.slice(0, match.index) + prefix + text.slice(match.index + match[0].length);
};
9 changes: 9 additions & 0 deletions test/todo-status.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ describe('Todo status matching', () => {
);
expect(removeTodoStatusTag('☐ Explain `@done`', tagFinished)).to.equal('☐ Explain `@done`');
});

it('preserves punctuation before status tags when unfinishing tasks', () => {
const tagFinished = /(?:^|[^a-zA-Z0-9])@(?:done|cancelled)(?:\([^)]*\))?/;
const tagElapsed = /(?:^|[^a-zA-Z0-9])@(?:lasted|wasted)(?:\([^)]*\))?/;

expect(removeTodoStatusTag('☐ Ship,@done', tagFinished)).to.equal('☐ Ship,');
expect(removeTodoStatusTag('☐ Ship!@cancelled(reason)', tagFinished)).to.equal('☐ Ship!');
expect(removeTodoStatusTag('☐ Ship,@lasted(2h)', tagElapsed)).to.equal('☐ Ship,');
});
});
Loading