Skip to content

Commit 9274c9d

Browse files
committed
fix: 'Tasks: Toggle task done' keeps list markers if no Global Filter (#3708)
This fixes #3708
1 parent 9091eda commit 9274c9d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Commands/ToggleDone.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const toggleLine = (line: string, path: string): EditorInsertion => {
102102
const statusString = regexMatch[3];
103103
const status = StatusRegistry.getInstance().bySymbol(statusString);
104104
const newStatusString = status.nextStatusSymbol;
105-
return { text: line.replace(TaskRegularExpressions.taskRegex, `$1- [${newStatusString}] $4`) };
105+
return { text: line.replace(TaskRegularExpressions.taskRegex, `$1$2 [${newStatusString}] $4`) };
106106
} else if (TaskRegularExpressions.listItemRegex.test(line)) {
107107
// Convert the list item to a checklist item.
108108
const text = line.replace(TaskRegularExpressions.listItemRegex, '$1$2 [ ]');

tests/Commands/ToggleDone.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ describe('ToggleDone', () => {
115115
testToggleLine('1. |foobar', '1. [ ] foobar|');
116116
});
117117

118-
it.failing('should complete a task', () => {
118+
it('should complete a task', () => {
119119
testToggleLine('|- [ ] ', '|- [x] ✅ 2022-09-04');
120120
testToggleLine('- [ ] |', '- [x] | ✅ 2022-09-04');
121121
testToggleLine('- [ ] description|', '- [x] description| ✅ 2022-09-04');
@@ -137,7 +137,7 @@ describe('ToggleDone', () => {
137137
testToggleLine('- [ ] I have a |proper description', '- [x] I have a |proper description');
138138
});
139139

140-
it.failing('should un-complete a completed task', () => {
140+
it('should un-complete a completed task', () => {
141141
testToggleLine('|- [x] ✅ 2022-09-04', '|- [ ] ');
142142
testToggleLine('1. [x] ✅ 2022-09-04|', '1. [ ] |');
143143

0 commit comments

Comments
 (0)