diff --git a/AUTHORS b/AUTHORS index 466af3427..4c751c34e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -160,4 +160,5 @@ suggestions: Jake Bell Florian Hollerweger Thomas Sullivan + Tim None diff --git a/ChangeLog b/ChangeLog index 461aedfd8..1ae988c2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,6 +54,8 @@ Bugs + Fixed bug #1065, where CmdShow issued messages in incorrect situations. + Partially fixed #1083, which showed 'task 0 ...' when modifying a non- pending task (thanks to Aikido Guy). + + Fixed bug #1123, which caused the undo of a 'log' command to corrupt the data + file (thanks to Tim None). + No more bash completion of, for example, 'projABC:', or of 'proj:' if abbreviation.minimum is greater than 4. + Fixed bug where shadow files are not properly created when there is a missing diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 199d32abb..c16402bd5 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -1576,26 +1576,37 @@ void TDB2::revert () { context.debug ("TDB::undo - task found in completed.data"); - // If task now belongs back in pending.data - if (prior.find ("status:\"pending\"") != std::string::npos || - prior.find ("status:\"waiting\"") != std::string::npos || - prior.find ("status:\"recurring\"") != std::string::npos) + // Either revert if there was a prior state, or remove the task. + if (prior != "") { - c.erase (task); - p.push_back (prior); - File::write (completed._file._data, c); - File::write (pending._file._data, p); - File::write (undo._file._data, u); - std::cout << STRING_TDB2_REVERTED << "\n"; - context.debug ("TDB::undo - task belongs in pending.data"); + *task = prior; + if (task->find ("status:\"pending\"") != std::string::npos || + task->find ("status:\"waiting\"") != std::string::npos || + task->find ("status:\"recurring\"") != std::string::npos) + { + c.erase (task); + p.push_back (prior); + File::write (completed._file._data, c); + File::write (pending._file._data, p); + File::write (undo._file._data, u); + std::cout << STRING_TDB2_REVERTED << "\n"; + context.debug ("TDB::undo - task belongs in pending.data"); + } + else + { + File::write (completed._file._data, c); + File::write (undo._file._data, u); + std::cout << STRING_TDB2_REVERTED << "\n"; + context.debug ("TDB::undo - task belongs in completed.data"); + } } else { - *task = prior; + c.erase (task); File::write (completed._file._data, c); File::write (undo._file._data, u); std::cout << STRING_TDB2_REVERTED << "\n"; - context.debug ("TDB::undo - task belongs in completed.data"); + context.debug ("TDB::undo - task removed"); } std::cout << STRING_TDB2_UNDO_COMPLETE << "\n";