From d43fa664894d61306c651a94ca69507aaa2c75e0 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Thu, 26 Nov 2020 23:48:56 -0500 Subject: [PATCH] CmdPurge: Detect the failure mode of trying to purge non-deleted tasks Prompted by the failure mode described by Glen Solsberry in #2254. --- src/commands/CmdPurge.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commands/CmdPurge.cpp b/src/commands/CmdPurge.cpp index f78ae39c6..1ed01e662 100644 --- a/src/commands/CmdPurge.cpp +++ b/src/commands/CmdPurge.cpp @@ -135,6 +135,7 @@ int CmdPurge::execute (std::string&) { int rc = 0; int count = 0; + bool matched_deleted = false; Filter filter; std::vector filtered; @@ -156,6 +157,9 @@ int CmdPurge::execute (std::string&) // mark tasks as deleted before purging. if (task.getStatus () == Task::deleted) { + // Mark that at least one deleted task matched the filter + matched_deleted = true; + std::string question; question = format ("Permanently remove task {1} '{2}'?", task.identifier (true), @@ -166,6 +170,9 @@ int CmdPurge::execute (std::string&) } } + if (filtered.size () > 0 and ! matched_deleted) + Context::getContext ().footnote ("No deleted tasks specified. Maybe you forgot to delete tasks first?"); + feedback_affected (count == 1 ? "Purged {1} task." : "Purged {1} tasks.", count); return rc; }