diff --git a/src/TDB2.cpp b/src/TDB2.cpp index 2b434bd6f..61b2f344d 100644 --- a/src/TDB2.cpp +++ b/src/TDB2.cpp @@ -1287,6 +1287,13 @@ int TDB2::next_id () return _id++; } +//////////////////////////////////////////////////////////////////////////////// +// Latest ID is that of the last pending task. +int TDB2::latest_id () +{ + return _id - 1; +} + //////////////////////////////////////////////////////////////////////////////// const std::vector TDB2::all_tasks () { diff --git a/src/TDB2.h b/src/TDB2.h index 8f1912365..f41d7d357 100644 --- a/src/TDB2.h +++ b/src/TDB2.h @@ -107,6 +107,7 @@ public: void revert (); int gc (); int next_id (); + int latest_id (); // Generalized task accessors. const std::vector all_tasks (); diff --git a/src/Task.cpp b/src/Task.cpp index 90239906b..a28034180 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1196,8 +1196,9 @@ bool Task::hasTag (const std::string& tag) const if (tag == "PENDING") return get ("status") == "pending"; if (tag == "COMPLETED") return get ("status") == "completed"; if (tag == "DELETED") return get ("status") == "deleted"; - if (tag == "UDA") return is_udaPresent(); - if (tag == "ORPHAN") return is_orphanPresent(); + if (tag == "UDA") return is_udaPresent (); + if (tag == "ORPHAN") return is_orphanPresent (); + if (tag == "LATEST") return id == context.tdb2.latest_id (); // Concrete tags. std::vector tags; diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index d22d6e39f..3870b1147 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -337,6 +337,7 @@ int CmdInfo::execute (std::string& output) if (task.hasTag ("WEEK")) virtualTags += "WEEK "; if (task.hasTag ("YEAR")) virtualTags += "YEAR "; if (task.hasTag ("YESTERDAY")) virtualTags += "YESTERDAY "; + if (task.hasTag ("LATEST")) virtualTags += "LATEST "; // If you update the above list, update src/commands/CmdInfo.cpp and src/commands/CmdTags.cpp as well. row = view.addRow ();