TI-58: Fix bug 'Delete command is not always deleting'

- Update database before deleting sythetic intervals
- Make Exclusion::ranges work with open interval
This commit is contained in:
Thomas Lauf 2017-04-05 22:53:53 +02:00
parent 98218c4b75
commit ad67539f94
4 changed files with 35 additions and 3 deletions

View file

@ -50,12 +50,32 @@ int CmdDelete (
Interval filter;
auto tracked = getTracked (database, rules, filter);
// Apply tags to ids.
bool dirty = true;
for (auto& id : ids)
{
if (id > static_cast <int> (tracked.size ()))
throw format ("ID '@{1}' does not correspond to any tracking.", id);
if (tracked[tracked.size() - id].synthetic && dirty)
{
auto latest = getLatestInterval(database);
auto exclusions = getAllExclusions (rules, filter.range);
Interval modified {latest};
// Update database.
database.deleteInterval (latest);
for (auto& interval : flatten (modified, exclusions))
database.addInterval (interval);
dirty = false;
}
}
// Delete intervals by id
for (auto& id : ids)
{
database.deleteInterval (tracked[tracked.size () - id]);
if (rules.getBoolean ("verbose"))