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

- Skipped false embedded-todo scan candidates when custom expressions match without a non-empty marker.
- Accepted an explicit leading `+` in time estimates and other duration expressions, alongside existing negative durations.
- Preserved balanced closing parentheses, brackets, and braces in relative file-link filenames while excluding surrounding punctuation.
- Preserved unsaved archive buffers, serialized simultaneous transfers, and replaced closed archive files only after a complete write. Failed writes, stale source documents, and rejected editor edits keep source tasks intact.
Expand Down
3 changes: 2 additions & 1 deletion src/utils/embedded/regex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export const hasEmbeddedMatch = (content: string, regex: RegExp): boolean => {
const matcher = new RegExp(regex.source, regex.flags);

return splitLines(content).some((line) => {
const trimmed = _.trimStart(line);
matcher.lastIndex = 0;

return matcher.test(_.trimStart(line));
return matcher.test(trimmed) && parseEmbeddedMatches(trimmed, regex).length > 0;
});
};
12 changes: 12 additions & 0 deletions test/embedded-regex.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ describe('Embedded todo scan pre-check', () => {

expect(hasEmbeddedMatch('const ready = true;\r // TASK ship it', regex)).to.equal(true);
});

it('skips matches without a configured marker capture', () => {
const regex = /(TODO)?(hello)/g;
expect(hasEmbeddedMatch('hello', regex)).to.equal(false);
expect(hasEmbeddedMatch('TODOhello', regex)).to.equal(true);
});

it('finds a later valid match after an empty alternative', () => {
const regex = /(TODO)|(?:)/g;
expect(hasEmbeddedMatch('nothing', regex)).to.equal(false);
expect(hasEmbeddedMatch(' TODO', regex)).to.equal(true);
});
});

describe('Embedded todo line parsing', () => {
Expand Down
Loading