From ccb5f00aae2491b8a47abf1e8bad13bdb75214ba Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Sun, 7 Dec 2025 13:35:24 +0000 Subject: [PATCH 1/4] test: - Add test for never-before tested code. The test passes. --- tests/Commands/ToggleDone.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Commands/ToggleDone.test.ts b/tests/Commands/ToggleDone.test.ts index 1a3f19f0b1..213a24dce1 100644 --- a/tests/Commands/ToggleDone.test.ts +++ b/tests/Commands/ToggleDone.test.ts @@ -106,13 +106,13 @@ describe('ToggleDone', () => { it('should add checkbox to hyphen and space', () => { testToggleLine('|- ', '- [ ] |'); testToggleLine('- |', '- [ ] |'); - testToggleLine('- |foobar', '- [ ] foobar|'); + testToggleLine('1. |foobar', '1. [ ] foobar|'); GlobalFilter.getInstance().set('#task'); testToggleLine('|- ', '- [ ] |'); testToggleLine('- |', '- [ ] |'); - testToggleLine('- |foobar', '- [ ] foobar|'); + testToggleLine('1. |foobar', '1. [ ] foobar|'); }); it('should complete a task', () => { From 932a380931c241f62a12e6f1cd8df332f5ecae29 Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Sun, 7 Dec 2025 13:49:19 +0000 Subject: [PATCH 2/4] test: - Add preparatory tests for #3708 --- tests/Commands/ToggleDone.test.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Commands/ToggleDone.test.ts b/tests/Commands/ToggleDone.test.ts index 213a24dce1..3b4bc77e4b 100644 --- a/tests/Commands/ToggleDone.test.ts +++ b/tests/Commands/ToggleDone.test.ts @@ -118,15 +118,21 @@ describe('ToggleDone', () => { it('should complete a task', () => { testToggleLine('|- [ ] ', '|- [x] ✅ 2022-09-04'); testToggleLine('- [ ] |', '- [x] | ✅ 2022-09-04'); + testToggleLine('- [ ] description|', '- [x] description| ✅ 2022-09-04'); // Issue #449 - cursor jumped 13 characters to the right on completion testToggleLine('- [ ] I have a |proper description', '- [x] I have a |proper description ✅ 2022-09-04'); GlobalFilter.getInstance().set('#task'); + // Done date is not added if task does not match global filter testToggleLine('|- [ ] ', '|- [x] '); testToggleLine('- [ ] |', '- [x] |'); + // Done date is added if task does not match global filter + testToggleLine('- [ ] #task|', '- [x] #tas|k ✅ 2022-09-04'); // Extra space added before #; cursor moves left + testToggleLine('- [ ] #task description|', '- [x] #task description| ✅ 2022-09-04'); + // Issue #449 - cursor jumped 13 characters to the right on completion testToggleLine('- [ ] I have a |proper description', '- [x] I have a |proper description'); }); @@ -144,6 +150,10 @@ describe('ToggleDone', () => { testToggleLine('|- [x] ✅ 2022-09-04', '|- [ ] ✅ 2022-09-04'); testToggleLine('- [x] ✅ 2022-09-04|', '- [ ] ✅ 2022-09-04|'); + // Done date is added if task matches the global filter + testToggleLine('|- [x] #task ✅ 2022-09-04', '|- [ ] #task'); // Extra space added before # + testToggleLine('- [x] #task description ✅ 2022-09-04|', '- [ ] #task description|'); + // Issue #449 - cursor jumped 13 characters to the left on un-completion testToggleLine( '- [x] I have a proper description| ✅ 2022-09-04', From 9091eda56bafb6bcd8fa9d42b2b302b00e331f21 Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Sun, 7 Dec 2025 13:53:36 +0000 Subject: [PATCH 3/4] test: - Add failing tests for #3708 --- tests/Commands/ToggleDone.test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Commands/ToggleDone.test.ts b/tests/Commands/ToggleDone.test.ts index 3b4bc77e4b..920bee02b7 100644 --- a/tests/Commands/ToggleDone.test.ts +++ b/tests/Commands/ToggleDone.test.ts @@ -115,7 +115,7 @@ describe('ToggleDone', () => { testToggleLine('1. |foobar', '1. [ ] foobar|'); }); - it('should complete a task', () => { + it.failing('should complete a task', () => { testToggleLine('|- [ ] ', '|- [x] ✅ 2022-09-04'); testToggleLine('- [ ] |', '- [x] | ✅ 2022-09-04'); testToggleLine('- [ ] description|', '- [x] description| ✅ 2022-09-04'); @@ -127,19 +127,19 @@ describe('ToggleDone', () => { // Done date is not added if task does not match global filter testToggleLine('|- [ ] ', '|- [x] '); - testToggleLine('- [ ] |', '- [x] |'); + testToggleLine('1. [ ] |', '1. [x] |'); // Done date is added if task does not match global filter testToggleLine('- [ ] #task|', '- [x] #tas|k ✅ 2022-09-04'); // Extra space added before #; cursor moves left - testToggleLine('- [ ] #task description|', '- [x] #task description| ✅ 2022-09-04'); + testToggleLine('* [ ] #task description|', '* [x] #task description| ✅ 2022-09-04'); // Issue #449 - cursor jumped 13 characters to the right on completion testToggleLine('- [ ] I have a |proper description', '- [x] I have a |proper description'); }); - it('should un-complete a completed task', () => { + it.failing('should un-complete a completed task', () => { testToggleLine('|- [x] ✅ 2022-09-04', '|- [ ] '); - testToggleLine('- [x] ✅ 2022-09-04|', '- [ ] |'); + testToggleLine('1. [x] ✅ 2022-09-04|', '1. [ ] |'); // Issue #449 - cursor jumped 13 characters to the left on un-completion testToggleLine('- [x] I have a proper description| ✅ 2022-09-04', '- [ ] I have a proper description|'); @@ -148,11 +148,11 @@ describe('ToggleDone', () => { // Done date is not removed if task does not match global filter testToggleLine('|- [x] ✅ 2022-09-04', '|- [ ] ✅ 2022-09-04'); - testToggleLine('- [x] ✅ 2022-09-04|', '- [ ] ✅ 2022-09-04|'); + testToggleLine('+ [x] ✅ 2022-09-04|', '+ [ ] ✅ 2022-09-04|'); // Done date is added if task matches the global filter testToggleLine('|- [x] #task ✅ 2022-09-04', '|- [ ] #task'); // Extra space added before # - testToggleLine('- [x] #task description ✅ 2022-09-04|', '- [ ] #task description|'); + testToggleLine('1. [x] #task description ✅ 2022-09-04|', '1. [ ] #task description|'); // Issue #449 - cursor jumped 13 characters to the left on un-completion testToggleLine( From 9274c9da613c5775596d023a9254345478352c76 Mon Sep 17 00:00:00 2001 From: Clare Macrae Date: Sun, 7 Dec 2025 13:56:01 +0000 Subject: [PATCH 4/4] fix: 'Tasks: Toggle task done' keeps list markers if no Global Filter (#3708) This fixes #3708 --- src/Commands/ToggleDone.ts | 2 +- tests/Commands/ToggleDone.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/ToggleDone.ts b/src/Commands/ToggleDone.ts index 877f2d40f2..91931dd99d 100644 --- a/src/Commands/ToggleDone.ts +++ b/src/Commands/ToggleDone.ts @@ -102,7 +102,7 @@ export const toggleLine = (line: string, path: string): EditorInsertion => { const statusString = regexMatch[3]; const status = StatusRegistry.getInstance().bySymbol(statusString); const newStatusString = status.nextStatusSymbol; - return { text: line.replace(TaskRegularExpressions.taskRegex, `$1- [${newStatusString}] $4`) }; + return { text: line.replace(TaskRegularExpressions.taskRegex, `$1$2 [${newStatusString}] $4`) }; } else if (TaskRegularExpressions.listItemRegex.test(line)) { // Convert the list item to a checklist item. const text = line.replace(TaskRegularExpressions.listItemRegex, '$1$2 [ ]'); diff --git a/tests/Commands/ToggleDone.test.ts b/tests/Commands/ToggleDone.test.ts index 920bee02b7..68814e5e22 100644 --- a/tests/Commands/ToggleDone.test.ts +++ b/tests/Commands/ToggleDone.test.ts @@ -115,7 +115,7 @@ describe('ToggleDone', () => { testToggleLine('1. |foobar', '1. [ ] foobar|'); }); - it.failing('should complete a task', () => { + it('should complete a task', () => { testToggleLine('|- [ ] ', '|- [x] ✅ 2022-09-04'); testToggleLine('- [ ] |', '- [x] | ✅ 2022-09-04'); testToggleLine('- [ ] description|', '- [x] description| ✅ 2022-09-04'); @@ -137,7 +137,7 @@ describe('ToggleDone', () => { testToggleLine('- [ ] I have a |proper description', '- [x] I have a |proper description'); }); - it.failing('should un-complete a completed task', () => { + it('should un-complete a completed task', () => { testToggleLine('|- [x] ✅ 2022-09-04', '|- [ ] '); testToggleLine('1. [x] ✅ 2022-09-04|', '1. [ ] |');