cli on delete todo, write in Done identified by entire struct so dupes wouldnt but thats ok

This commit is contained in:
Bel LaPointe
2022-03-23 09:46:16 -06:00
parent 5a1936721d
commit 1b1ed01937
2 changed files with 22 additions and 3 deletions

View File

@@ -167,7 +167,18 @@ func edit(dry bool, filepaths []string) error {
return err
}
original := originals[target]
newTodoIDs := map[string]struct{}{}
for i := range newTodos {
newTodoIDs[newTodos[i].ID()] = struct{}{}
}
for i := range original.Todo {
if _, ok := newTodoIDs[original.Todo[i].ID()]; !ok {
original.Done = append(original.Done, original.Todo[i])
}
}
original.Todo = newTodos
original.AutoMove()
c, err := yaml.Marshal(original)
if err != nil {