From d74c20fc04dcbeecb7e0f009089f236b1ecf514c Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 18 Jul 2024 00:39:22 +0300 Subject: [PATCH] Automatically move up a task on invalid input --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4aef894..d1d4cac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,7 +109,8 @@ async fn repl() { } match input.split_once(": ") { None => { - position = EventId::parse(input).ok(); + position = EventId::parse(input).ok().or( + position.and_then(|p| tasks.get(&p)).and_then(|t| t.parent_id())); } Some(s) => { let mut tags: Vec = s.1.split(" ").map(|t| Tag::Hashtag(t.to_string())).collect();