mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CmdEdit: Do not bump annotation timestamps without need
This commit is contained in:
parent
89df8e5c8a
commit
023cc3c383
1 changed files with 12 additions and 5 deletions
|
@ -644,13 +644,20 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||||
// if there is no corresponding id, then a new unique date is created).
|
// if there is no corresponding id, then a new unique date is created).
|
||||||
Date when (value.substr (0, gap), dateformat);
|
Date when (value.substr (0, gap), dateformat);
|
||||||
|
|
||||||
// This guarantees that if more than one annotation has the same date,
|
// If the map already contains a annotation for a given timestamp
|
||||||
// that the seconds will be different, thus unique, thus not squashed.
|
// we need to increment until we find an unused key
|
||||||
// Bug #249
|
int timestamp = (int) when.toEpoch ();
|
||||||
when += (const int) annotations.size ();
|
|
||||||
|
|
||||||
std::stringstream name;
|
std::stringstream name;
|
||||||
name << "annotation_" << when.toEpoch ();
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
name.str (""); // Clear
|
||||||
|
name << "annotation_" << timestamp;
|
||||||
|
timestamp++;
|
||||||
|
}
|
||||||
|
while (annotations.find (name.str ()) != annotations.end ());
|
||||||
|
|
||||||
std::string text = trim (value.substr (gap + 4), "\t ");
|
std::string text = trim (value.substr (gap + 4), "\t ");
|
||||||
annotations.insert (std::make_pair (name.str (), json::decode (text)));
|
annotations.insert (std::make_pair (name.str (), json::decode (text)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue