From 1b2cfd427c83ef94d2e82eb0c35c3fcc5b2fe5ea Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Tue, 20 Jul 2010 13:59:58 +0200 Subject: [PATCH] Bug #427 - Task edit can't correctly parse annotations with times Task edit was assuming a space as separator between the date and text field of an annotation. As the dateformat for an annotation now can be more flexible incl. time and spaces, task couldn't parse the annotation lines of task edit correctly anymore. The bug was fixed by introducing a new separator ' --' between the date and text parts of an annotation. --- src/edit.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/edit.cpp b/src/edit.cpp index 069dc105c..74e78fb7e 100644 --- a/src/edit.cpp +++ b/src/edit.cpp @@ -156,8 +156,8 @@ static std::string formatTask (Task task) << " Parent: " << task.get ("parent") << std::endl << " Foreground color: " << task.get ("fg") << std::endl << " Background color: " << task.get ("bg") << std::endl - << "# Annotations look like this: , and there can be any number" << std::endl - << "# of them." << std::endl; + << "# Annotations look like this: -- and there can be any number of them" << std::endl + << "# ' -- ' is the separator between the date and text field. It should not be removed" << std::endl; std::vector annotations; task.getAnnotations (annotations); @@ -165,11 +165,11 @@ static std::string formatTask (Task task) { Date dt (::atoi (anno->name ().substr (11).c_str ())); before << " Annotation: " << dt.toString (context.config.get ("dateformat.annotation")) - << " " << anno->value () << std::endl; + << " -- " << anno->value () << std::endl; } Date now; - before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " " << std::endl + before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " -- " << std::endl << "# End" << std::endl; return before.str (); @@ -499,7 +499,7 @@ static void parseTask (Task& task, const std::string& after) found, eol - found), "\t "); - std::string::size_type gap = value.find (" "); + std::string::size_type gap = value.find (" -- "); if (gap != std::string::npos) { Date when (value.substr (0, gap), context.config.get ("dateformat.annotation")); @@ -511,7 +511,7 @@ static void parseTask (Task& task, const std::string& after) std::stringstream name; name << "annotation_" << when.toEpoch (); - std::string text = trim (value.substr (gap), "\t "); + std::string text = trim (value.substr (gap + 4), "\t "); annotations.push_back (Att (name.str (), text)); } }