Skip to content

Commit ccd292b

Browse files
committed
fix: Fix console error when 'Toggle task done' deletes the line
Fixes #3256
1 parent cfb36e3 commit ccd292b

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
@@ -75,7 +75,7 @@ export const toggleLine = (line: string, path: string): EditorInsertion => {
7575
});
7676
if (task !== null) {
7777
const lines = task.toggleWithRecurrenceInUsersOrder().map((t) => t.toFileLineString());
78-
const newLineNumber = lines.length - 1;
78+
const newLineNumber = lines.length > 0 ? lines.length - 1 : 0;
7979
return { text: lines.join('\n'), moveTo: { line: newLineNumber } };
8080
} else {
8181
// If the task is null this means that we have one of:

tests/Commands/ToggleDone.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe('ToggleDone', () => {
183183
});
184184

185185
describe('on completion', () => {
186-
it.failing('should delete a self-deleting task - cursor at start of line', () => {
186+
it('should delete a self-deleting task - cursor at start of line', () => {
187187
// Issue #3256 - traceback occurred.
188188
testToggleLine(
189189
// Force linebreak
@@ -192,7 +192,7 @@ describe('ToggleDone', () => {
192192
);
193193
});
194194

195-
it.failing('should delete a self-deleting task - cursor at end of line', () => {
195+
it('should delete a self-deleting task - cursor at end of line', () => {
196196
// Issue #3256 - traceback occurred.
197197
testToggleLine(
198198
// Force linebreak

0 commit comments

Comments
 (0)