mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Just set contextTask in Task::modify
Based on the observation that every command was setting contextTask immediately before calling `task.modify(..)`.
This commit is contained in:
parent
db26a28bf9
commit
2ea6dd627e
11 changed files with 5 additions and 42 deletions
|
@ -60,7 +60,7 @@
|
||||||
|
|
||||||
#define APPROACHING_INFINITY 1000 // Close enough. This isn't rocket surgery.
|
#define APPROACHING_INFINITY 1000 // Close enough. This isn't rocket surgery.
|
||||||
|
|
||||||
extern Task& contextTask;
|
extern Task* contextTask;
|
||||||
|
|
||||||
static const float epsilon = 0.000001;
|
static const float epsilon = 0.000001;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2271,6 +2271,10 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
{
|
{
|
||||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||||
|
|
||||||
|
// while reading the parse tree, consider DOM references in the context of
|
||||||
|
// this task
|
||||||
|
contextTask = this;
|
||||||
|
|
||||||
// Need this for later comparison.
|
// Need this for later comparison.
|
||||||
auto originalStatus = getStatus ();
|
auto originalStatus = getStatus ();
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdAdd::CmdAdd ()
|
CmdAdd::CmdAdd ()
|
||||||
{
|
{
|
||||||
|
@ -56,7 +54,6 @@ int CmdAdd::execute (std::string& output)
|
||||||
|
|
||||||
// the task is empty, but DOM references can refer to earlier parts of the
|
// the task is empty, but DOM references can refer to earlier parts of the
|
||||||
// command line, e.g., `task add due:20110101 wait:due`.
|
// command line, e.g., `task add due:20110101 wait:due`.
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modReplace, true);
|
task.modify (Task::modReplace, true);
|
||||||
Context::getContext ().tdb2.add (task);
|
Context::getContext ().tdb2.add (task);
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdAnnotate::CmdAnnotate ()
|
CmdAnnotate::CmdAnnotate ()
|
||||||
{
|
{
|
||||||
|
@ -84,7 +82,6 @@ int CmdAnnotate::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAnnotate, true);
|
task.modify (Task::modAnnotate, true);
|
||||||
|
|
||||||
if (permission (before.diff (task) + question, filtered.size ()))
|
if (permission (before.diff (task) + question, filtered.size ()))
|
||||||
|
@ -105,7 +102,6 @@ int CmdAnnotate::execute (std::string&)
|
||||||
auto siblings = Context::getContext ().tdb2.siblings (task);
|
auto siblings = Context::getContext ().tdb2.siblings (task);
|
||||||
for (auto& sibling : siblings)
|
for (auto& sibling : siblings)
|
||||||
{
|
{
|
||||||
contextTask = &sibling;
|
|
||||||
sibling.modify (Task::modAnnotate, true);
|
sibling.modify (Task::modAnnotate, true);
|
||||||
Context::getContext ().tdb2.modify (sibling);
|
Context::getContext ().tdb2.modify (sibling);
|
||||||
++count;
|
++count;
|
||||||
|
@ -115,7 +111,6 @@ int CmdAnnotate::execute (std::string&)
|
||||||
// Annotate the parent
|
// Annotate the parent
|
||||||
Task parent;
|
Task parent;
|
||||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||||
contextTask = &parent;
|
|
||||||
parent.modify (Task::modAnnotate, true);
|
parent.modify (Task::modAnnotate, true);
|
||||||
Context::getContext ().tdb2.modify (parent);
|
Context::getContext ().tdb2.modify (parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdAppend::CmdAppend ()
|
CmdAppend::CmdAppend ()
|
||||||
{
|
{
|
||||||
|
@ -84,7 +82,6 @@ int CmdAppend::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAppend, true);
|
task.modify (Task::modAppend, true);
|
||||||
|
|
||||||
if (permission (before.diff (task) + question, filtered.size ()))
|
if (permission (before.diff (task) + question, filtered.size ()))
|
||||||
|
@ -105,7 +102,6 @@ int CmdAppend::execute (std::string&)
|
||||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||||
for (auto& sibling : siblings)
|
for (auto& sibling : siblings)
|
||||||
{
|
{
|
||||||
contextTask = &sibling;
|
|
||||||
sibling.modify (Task::modAppend, true);
|
sibling.modify (Task::modAppend, true);
|
||||||
Context::getContext ().tdb2.modify (sibling);
|
Context::getContext ().tdb2.modify (sibling);
|
||||||
++count;
|
++count;
|
||||||
|
@ -115,7 +111,6 @@ int CmdAppend::execute (std::string&)
|
||||||
// Append to the parent
|
// Append to the parent
|
||||||
Task parent;
|
Task parent;
|
||||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||||
contextTask = &parent;
|
|
||||||
parent.modify (Task::modAppend, true);
|
parent.modify (Task::modAppend, true);
|
||||||
Context::getContext ().tdb2.modify (parent);
|
Context::getContext ().tdb2.modify (parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
#define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'."
|
#define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'."
|
||||||
#define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
#define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdDelete::CmdDelete ()
|
CmdDelete::CmdDelete ()
|
||||||
{
|
{
|
||||||
|
@ -89,7 +87,6 @@ int CmdDelete::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAnnotate);
|
task.modify (Task::modAnnotate);
|
||||||
task.setStatus (Task::deleted);
|
task.setStatus (Task::deleted);
|
||||||
if (! task.has ("end"))
|
if (! task.has ("end"))
|
||||||
|
@ -116,7 +113,6 @@ int CmdDelete::execute (std::string&)
|
||||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||||
for (auto& sibling : siblings)
|
for (auto& sibling : siblings)
|
||||||
{
|
{
|
||||||
contextTask = &sibling;
|
|
||||||
sibling.modify (Task::modAnnotate);
|
sibling.modify (Task::modAnnotate);
|
||||||
sibling.setStatus (Task::deleted);
|
sibling.setStatus (Task::deleted);
|
||||||
if (! sibling.has ("end"))
|
if (! sibling.has ("end"))
|
||||||
|
@ -151,7 +147,6 @@ int CmdDelete::execute (std::string&)
|
||||||
{
|
{
|
||||||
for (auto& child : children)
|
for (auto& child : children)
|
||||||
{
|
{
|
||||||
contextTask = &child;
|
|
||||||
child.modify (Task::modAnnotate);
|
child.modify (Task::modAnnotate);
|
||||||
child.setStatus (Task::deleted);
|
child.setStatus (Task::deleted);
|
||||||
if (! child.has ("end"))
|
if (! child.has ("end"))
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdDone::CmdDone ()
|
CmdDone::CmdDone ()
|
||||||
{
|
{
|
||||||
|
@ -87,7 +85,6 @@ int CmdDone::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAnnotate);
|
task.modify (Task::modAnnotate);
|
||||||
task.setStatus (Task::completed);
|
task.setStatus (Task::completed);
|
||||||
if (! task.has ("end"))
|
if (! task.has ("end"))
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdDuplicate::CmdDuplicate ()
|
CmdDuplicate::CmdDuplicate ()
|
||||||
{
|
{
|
||||||
|
@ -102,7 +100,6 @@ int CmdDuplicate::execute (std::string&)
|
||||||
dup.setStatus (Task::pending); // Does not inherit status.
|
dup.setStatus (Task::pending); // Does not inherit status.
|
||||||
// Must occur after Task::recurring check.
|
// Must occur after Task::recurring check.
|
||||||
|
|
||||||
contextTask = &dup;
|
|
||||||
dup.modify (Task::modAnnotate);
|
dup.modify (Task::modAnnotate);
|
||||||
|
|
||||||
if (permission (format ("Duplicate task {1} '{2}'?",
|
if (permission (format ("Duplicate task {1} '{2}'?",
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
#define STRING_CMD_MODIFY_TASK_R "Modifying recurring task {1} '{2}'."
|
#define STRING_CMD_MODIFY_TASK_R "Modifying recurring task {1} '{2}'."
|
||||||
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdModify::CmdModify ()
|
CmdModify::CmdModify ()
|
||||||
{
|
{
|
||||||
|
@ -79,7 +77,6 @@ int CmdModify::execute (std::string&)
|
||||||
for (auto& task : filtered)
|
for (auto& task : filtered)
|
||||||
{
|
{
|
||||||
Task before (task);
|
Task before (task);
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modReplace);
|
task.modify (Task::modReplace);
|
||||||
|
|
||||||
if (before != task)
|
if (before != task)
|
||||||
|
@ -177,7 +174,6 @@ int CmdModify::modifyRecurrenceSiblings (
|
||||||
for (auto& sibling : siblings)
|
for (auto& sibling : siblings)
|
||||||
{
|
{
|
||||||
Task alternate (sibling);
|
Task alternate (sibling);
|
||||||
contextTask = &sibling;
|
|
||||||
sibling.modify (Task::modReplace);
|
sibling.modify (Task::modReplace);
|
||||||
updateRecurrenceMask (sibling);
|
updateRecurrenceMask (sibling);
|
||||||
++count;
|
++count;
|
||||||
|
@ -191,7 +187,6 @@ int CmdModify::modifyRecurrenceSiblings (
|
||||||
// Modify the parent
|
// Modify the parent
|
||||||
Task parent;
|
Task parent;
|
||||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||||
contextTask = &parent;
|
|
||||||
parent.modify (Task::modReplace);
|
parent.modify (Task::modReplace);
|
||||||
Context::getContext ().tdb2.modify (parent);
|
Context::getContext ().tdb2.modify (parent);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +210,6 @@ int CmdModify::modifyRecurrenceParent (
|
||||||
for (auto& child : children)
|
for (auto& child : children)
|
||||||
{
|
{
|
||||||
Task alternate (child);
|
Task alternate (child);
|
||||||
contextTask = &child;
|
|
||||||
child.modify (Task::modReplace);
|
child.modify (Task::modReplace);
|
||||||
updateRecurrenceMask (child);
|
updateRecurrenceMask (child);
|
||||||
Context::getContext ().tdb2.modify (child);
|
Context::getContext ().tdb2.modify (child);
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdPrepend::CmdPrepend ()
|
CmdPrepend::CmdPrepend ()
|
||||||
{
|
{
|
||||||
|
@ -84,7 +82,6 @@ int CmdPrepend::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modPrepend, true);
|
task.modify (Task::modPrepend, true);
|
||||||
|
|
||||||
if (permission (before.diff (task) + question, filtered.size ()))
|
if (permission (before.diff (task) + question, filtered.size ()))
|
||||||
|
@ -105,7 +102,6 @@ int CmdPrepend::execute (std::string&)
|
||||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||||
for (auto& sibling : siblings)
|
for (auto& sibling : siblings)
|
||||||
{
|
{
|
||||||
contextTask = &sibling;
|
|
||||||
sibling.modify (Task::modPrepend, true);
|
sibling.modify (Task::modPrepend, true);
|
||||||
Context::getContext ().tdb2.modify (sibling);
|
Context::getContext ().tdb2.modify (sibling);
|
||||||
++count;
|
++count;
|
||||||
|
@ -115,7 +111,6 @@ int CmdPrepend::execute (std::string&)
|
||||||
// Prepend to the parent
|
// Prepend to the parent
|
||||||
Task parent;
|
Task parent;
|
||||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||||
contextTask = &parent;
|
|
||||||
parent.modify (Task::modPrepend, true);
|
parent.modify (Task::modPrepend, true);
|
||||||
Context::getContext ().tdb2.modify (parent);
|
Context::getContext ().tdb2.modify (parent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdStart::CmdStart ()
|
CmdStart::CmdStart ()
|
||||||
{
|
{
|
||||||
|
@ -85,7 +83,6 @@ int CmdStart::execute (std::string&)
|
||||||
std::string question = format ("Start task {1} '{2}'?",
|
std::string question = format ("Start task {1} '{2}'?",
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAnnotate);
|
task.modify (Task::modAnnotate);
|
||||||
task.setAsNow ("start");
|
task.setAsNow ("start");
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
|
||||||
extern Task* contextTask;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdStop::CmdStop ()
|
CmdStop::CmdStop ()
|
||||||
{
|
{
|
||||||
|
@ -83,7 +81,6 @@ int CmdStop::execute (std::string&)
|
||||||
task.identifier (true),
|
task.identifier (true),
|
||||||
task.get ("description"));
|
task.get ("description"));
|
||||||
|
|
||||||
contextTask = &task;
|
|
||||||
task.modify (Task::modAnnotate);
|
task.modify (Task::modAnnotate);
|
||||||
task.remove ("start");
|
task.remove ("start");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue