diff --git a/lib/core/checklist.dart b/lib/core/checklist.dart index 0a3dd74c..b011102f 100644 --- a/lib/core/checklist.dart +++ b/lib/core/checklist.dart @@ -91,8 +91,6 @@ class Checklist { } Note get note { - if (_lines.isEmpty) return _note; - for (var item in items) { _lines[item.lineNo] = item.toString(); } diff --git a/test/checklist_test.dart b/test/checklist_test.dart index 429c170d..d471f4ee 100644 --- a/test/checklist_test.dart +++ b/test/checklist_test.dart @@ -238,5 +238,39 @@ Booga Wooga note = checklist.note; expect(note.body, "- [X] One\n- [ ] Two"); }); + + test('Empty Checklist', () async { + var content = "[X] One\n"; + + var notePath = p.join(tempDir.path, "note449.md"); + await File(notePath).writeAsString(content); + + var parentFolder = NotesFolderFS(null, tempDir.path); + var note = Note(parentFolder, notePath); + await note.load(); + + var checklist = Checklist(note); + checklist.removeAt(0); + + note = checklist.note; + expect(note.body, "\n"); + }); + + test('Checklist Header only', () async { + var content = "#Title\n[X] One\n"; + + var notePath = p.join(tempDir.path, "note429.md"); + await File(notePath).writeAsString(content); + + var parentFolder = NotesFolderFS(null, tempDir.path); + var note = Note(parentFolder, notePath); + await note.load(); + + var checklist = Checklist(note); + checklist.removeAt(0); + + note = checklist.note; + expect(note.body, "#Title\n"); + }); }); }