@@ -42,19 +42,16 @@ export const toggleDone = (checking: boolean, editor: Editor, view: MarkdownView
42
42
const taskIsOnLastLine = ! taskWasNotOnLastLine ;
43
43
if ( replacementTextIsNonEmpty ) {
44
44
editor . setLine ( lineNumber , insertion . text ) ;
45
- } else {
45
+ } else if ( taskIsOnLastLine ) {
46
46
// https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3342
47
- // If insertion.text is empty, delete the line instead, so we don't leave a trailing end-of-line character around.
48
- if ( taskIsOnLastLine ) {
49
- // There is no end-of-line character on our line, which is the last line in the file.
50
- // console.log(`Deleting line "${editor.getLine(lineNumber)}", because insertion.text is empty.`);
51
- editor . setLine ( lineNumber , insertion . text ) ;
52
- } else {
53
- const from = { line : lineNumber , ch : 0 } ;
54
- const to = { line : lineNumber + 1 , ch : 0 } ;
55
- // console.log(`Deleting line+EOL "${editor.getRange(from, to)}", because insertion.text is empty.`);
56
- editor . replaceRange ( '' , from , to ) ;
57
- }
47
+ // There is no end-of-line character on our line, which is the last line in the file.
48
+ // console.log(`Deleting line "${editor.getLine(lineNumber)}", because insertion.text is empty.`);
49
+ editor . setLine ( lineNumber , insertion . text ) ;
50
+ } else {
51
+ const from = { line : lineNumber , ch : 0 } ;
52
+ const to = { line : lineNumber + 1 , ch : 0 } ;
53
+ // console.log(`Deleting line+EOL "${editor.getRange(from, to)}", because insertion.text is empty.`);
54
+ editor . replaceRange ( '' , from , to ) ;
58
55
}
59
56
60
57
/* Cursor positions are 0-based for both "line" and "ch" offsets.
0 commit comments