CmdStart: Honor the :adjust flag when overwriting a currently open interval

Move the adjustment of a new open interval that is enclosed by the
current open interval into the validation processing, where the other
overlap resolution takes place.

This will allow the start command to honor the :adjust flag when
starting a new interval that predates the current open interval.

Closes #326

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Shaun Ruffell 2020-06-08 06:13:00 +02:00 committed by Thomas Lauf
parent 1c1066ae6c
commit cc82f468e1
3 changed files with 43 additions and 57 deletions

View file

@ -99,6 +99,23 @@ static void autoAdjust (
{
const bool verbose = rules.getBoolean ("verbose");
// We do not need the adjust flag set to "flatten" the database if the last
// interval is open and encloses the current interval that we're adding.
Interval latest = getLatestInterval (database);
if (interval.is_open () && latest.encloses (interval))
{
database.deleteInterval (latest);
latest.end = interval.start;
for (auto& interval : flatten (latest, getAllExclusions (rules, latest)))
{
database.addInterval (interval, verbose);
if (verbose)
{
std::cout << intervalSummarize (database, rules, interval);
}
}
}
Interval overlaps_filter {interval.start, interval.end};
auto overlaps = getTracked (database, rules, overlaps_filter);