Skip to content

Commit d32ef65

Browse files
committed
refactor: . Flip if/else
1 parent 7ba5502 commit d32ef65

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Commands/ToggleDone.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ export const toggleDone = (checking: boolean, editor: Editor, view: MarkdownView
4444
} else {
4545
// https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3342
4646
// If insertion.text is empty, delete the line instead, so we don't leave a trailing end-of-line character around.
47-
if (taskWasNotOnLastLine) {
47+
if (!taskWasNotOnLastLine) {
48+
// There is no end-of-line character on our line, which is the last line in the file.
49+
// console.log(`Deleting line "${editor.getLine(lineNumber)}", because insertion.text is empty.`);
50+
editor.setLine(lineNumber, insertion.text);
51+
} else {
4852
const from = { line: lineNumber, ch: 0 };
4953
const to = { line: lineNumber + 1, ch: 0 };
5054
// console.log(`Deleting line+EOL "${editor.getRange(from, to)}", because insertion.text is empty.`);
5155
editor.replaceRange('', from, to);
52-
} else {
53-
// There is no end-of-line character on our line, which is the last line in the file.
54-
// console.log(`Deleting line "${editor.getLine(lineNumber)}", because insertion.text is empty.`);
55-
editor.setLine(lineNumber, insertion.text);
5656
}
5757
}
5858

0 commit comments

Comments
 (0)