diff --git a/autotodo/data/notes.md b/autotodo/data/notes.md index e69de29..3b206b1 100644 --- a/autotodo/data/notes.md +++ b/autotodo/data/notes.md @@ -0,0 +1,18 @@ +# 27.01.2026 + +- [ ] Test 1 +- [ ] Test 2 + +# 28.01.2026 + +- [x] Test 1 +- [ ] Test 2 +- [ ] Test 3 +- [x] Test 4 +- [x] Test 5 + +# 2026-01-29 + +- [ ] Test 2 +- [ ] Test 3 + diff --git a/autotodo/src/main.rs b/autotodo/src/main.rs index 7b4f31e..106082e 100644 --- a/autotodo/src/main.rs +++ b/autotodo/src/main.rs @@ -94,7 +94,6 @@ fn update_notes(notes_path: &Path) { linebuf.clear(); } - // Find duplicates let mut todos_hashset: HashSet<&str> = HashSet::new(); let split_lines = all_lines.rsplit("\n"); for (rev_idx, line) in split_lines.enumerate() { @@ -107,13 +106,8 @@ fn update_notes(notes_path: &Path) { let Some(todotext) = trimmed_str.get(6..) else { continue; }; - if !todos_hashset.insert(todotext) { - // false if dupl + if !todos_hashset.insert(todotext) || is_done(prefix) { lines_to_not_use.push(org_idx); - } else { - if is_done(prefix) { - lines_to_not_use.push(org_idx); - } } } @@ -136,15 +130,14 @@ fn update_notes(notes_path: &Path) { let mut cur = lines_to_not_use.len() - 1; for (idx, line) in all_lines.split("\n").enumerate() { - if cur > 0 && lines_to_not_use.get(cur).unwrap() == &idx { - cur -= 1; + if lines_to_not_use.get(cur).unwrap() == &idx { + cur = cur.saturating_sub(1); } else { writeln!(linebuf, "{line}").unwrap_or_else(|e| panic!("{e}")); } } file.write_all(linebuf.as_bytes()).unwrap_or_else(|e| panic!("Maaan look out for these files. Error is: {e}")); - // dbg!(&linebuf); } // fn parse_patterns(notes_path: &Path, patterns_path: &Path) {