Nag based on task state before modification

With this patch, taskwarrior uses the urgency of tasks before any
modifications are applied when deciding whether to show nag messages.

Previously, taskwarrior would apply modifications before deciding
whether to show nag messages, which could lead to spurious nag messages
when completing an active task.
This commit is contained in:
Korrat 2021-07-22 17:08:00 +02:00 committed by Tomas Babej
parent 607baa081d
commit b33a99a748
5 changed files with 98 additions and 33 deletions

View file

@ -68,10 +68,11 @@ int CmdStart::execute (std::string&)
// Accumulated project change notifications.
std::map <std::string, std::string> projectChanges;
bool nagged = false;
if(filtered.size() > 1) {
feedback_affected("This command will alter {1} tasks.", filtered.size());
}
std::vector <Task> modified;
for (auto& task : filtered)
{
if (! task.has ("start"))
@ -101,11 +102,12 @@ int CmdStart::execute (std::string&)
Context::getContext ().tdb2.modify (task);
++count;
feedback_affected ("Starting task {1} '{2}'.", task);
if (!nagged)
nagged = nag (task);
dependencyChainOnStart (task);
if (Context::getContext ().verbose ("project"))
projectChanges[task.get ("project")] = onProjectChange (task, false);
// Save unmodified task for potential nagging later
modified.push_back(before);
}
else
{
@ -125,6 +127,8 @@ int CmdStart::execute (std::string&)
}
}
nag (modified);
// Now list the project changes.
for (auto& change : projectChanges)
if (change.first != "")