From 9d5fa3e2445f7e37e1f5aa45a642ed8ebf18ee98 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Tue, 8 Apr 2025 20:06:25 +0200 Subject: [PATCH] feat: Only annotate tasks if note file was created In the case of opening the notes but then backing out again without actually writing a notes file we should also not annotate the task with anything, since it technically still does not have a note. --- topen.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/topen.py b/topen.py index a388b57..b2206ef 100755 --- a/topen.py +++ b/topen.py @@ -57,11 +57,12 @@ def main(): if not uuid: _ = sys.stderr.write(f"Could not find task for ID: {cfg.task_id}.") sys.exit(1) - fname = get_notes_file(uuid, notes_dir=cfg.notes_dir, notes_ext=cfg.notes_ext) + fpath = get_notes_file(uuid, notes_dir=cfg.notes_dir, notes_ext=cfg.notes_ext) - open_editor(fname, editor=cfg.notes_editor) + open_editor(fpath, editor=cfg.notes_editor) - add_annotation_if_missing(task, annotation_content=cfg.notes_annot) + if fpath.exists(): + add_annotation_if_missing(task, annotation_content=cfg.notes_annot) def get_task(id: str | int, data_location: Path) -> Task: