diff --git a/ChangeLog b/ChangeLog index 67a8fcbf5..d4675334b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -43,6 +43,8 @@ values. + Fixed bug #444, which made task shell unusable after canceling out of an undo command. + + Fixed bug #449, so the wait: attribute can be applied to a task at any + time, not just on add. ------ old releases ------------------------------ diff --git a/src/command.cpp b/src/command.cpp index fb10ba4f0..56e4ed14e 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -69,8 +69,12 @@ int handleAdd (std::string &outs) context.task.setStatus (Task::recurring); context.task.set ("mask", ""); } + + // Tasks with a wait: date get a special status. else if (context.task.has ("wait")) context.task.setStatus (Task::waiting); + + // By default, tasks are pending. else context.task.setStatus (Task::pending); @@ -1335,7 +1339,8 @@ int handleDone (std::string &outs) bool nagged = false; foreach (task, tasks) { - if ((task->getStatus () == Task::pending) || (task->getStatus () == Task::waiting)) + if (task->getStatus () == Task::pending || + task->getStatus () == Task::waiting) { Task before (*task); @@ -2298,9 +2303,15 @@ int deltaAttributes (Task& task) if (att->second.name () == "wait") { if (att->second.value () == "") + { + task.remove (att->first); task.setStatus (Task::pending); + } else + { + task.set (att->first, att->second.value ()); task.setStatus (Task::waiting); + } } // Modifying dependencies requires adding/removing uuids. diff --git a/src/import.cpp b/src/import.cpp index 0c5fb95c5..7815de337 100644 --- a/src/import.cpp +++ b/src/import.cpp @@ -1075,6 +1075,7 @@ static std::string importCSV (const std::vector & lines) { std::string value = lowerCase (unquoteText (trim (fields[f]))); + // TODO What happened to "pending"? if (value == "recurring") task.setStatus (Task::recurring); else if (value == "deleted") task.setStatus (Task::deleted); else if (value == "completed") task.setStatus (Task::completed); diff --git a/src/tests/wait.t b/src/tests/wait.t index a75c952d4..2f2ef76f5 100755 --- a/src/tests/wait.t +++ b/src/tests/wait.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 13; # Create the rc file. if (open my $fh, '>', 'wait.rc') @@ -41,15 +41,25 @@ if (open my $fh, '>', 'wait.rc') } # Add a waiting task, check it is not there, wait, then check it is. -qx{../task rc:wait.rc add -- yeswait}; -qx{../task rc:wait.rc add -- nowait}; -qx{../task rc:wait.rc 1 wait:1s}; +qx{../task rc:wait.rc add yeswait wait:2s}; +qx{../task rc:wait.rc add nowait}; my $output = qx{../task rc:wait.rc ls}; like ($output, qr/nowait/ms, 'non-waiting task visible'); unlike ($output, qr/yeswait/ms, 'waiting task invisible'); -sleep 2; +sleep 3; + +$output = qx{../task rc:wait.rc ls}; +like ($output, qr/nowait/ms, 'non-waiting task still visible'); +like ($output, qr/yeswait/ms, 'waiting task now visible'); + +qx{../task rc:wait.rc 1 wait:2s}; +$output = qx{../task rc:wait.rc ls}; +like ($output, qr/nowait/ms, 'non-waiting task visible'); +unlike ($output, qr/yeswait/ms, 'waiting task invisible'); + +sleep 3; $output = qx{../task rc:wait.rc ls}; like ($output, qr/nowait/ms, 'non-waiting task still visible');