- TW-288 `task edit` mangles descriptions with embedded newlines (thanks to
         Kevin Ballard).
This commit is contained in:
Paul Beckingham 2014-07-06 12:14:44 -04:00
parent 68ceea953a
commit 0c1fa8b20e
4 changed files with 26 additions and 2 deletions

View file

@ -97,6 +97,26 @@ std::string CmdEdit::findValue (
return "";
}
////////////////////////////////////////////////////////////////////////////////
std::string CmdEdit::findMultilineValue (
const std::string& text,
const std::string& startMarker,
const std::string& endMarker)
{
std::string::size_type start = text.find (startMarker);
if (start != std::string::npos)
{
std::string::size_type end = text.find (endMarker, start);
if (end != std::string::npos)
{
std::string value = text.substr (start + startMarker.length (),
end - (start + startMarker.length ()));
return trim (value, "\t ");
}
}
return "";
}
////////////////////////////////////////////////////////////////////////////////
std::vector <std::string> CmdEdit::findValues (
const std::string& text,
@ -351,7 +371,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
task.addTags (tags);
// description.
value = findValue (after, "\n Description:");
value = findMultilineValue (after, "\n Description:", "\n Created:");
if (task.get ("description") != value)
{
if (value != "")
@ -717,7 +737,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
}
}
}
// UDA orphans
std::vector <std::string> orphanValues = findValues (after, "\n UDA Orphan ");
std::vector <std::string>::iterator orphan;

View file

@ -39,6 +39,7 @@ public:
private:
std::string findValue (const std::string&, const std::string&);
std::string findMultilineValue (const std::string&, const std::string&, const std::string&);
std::vector <std::string> findValues (const std::string&, const std::string&);
std::string formatDate (Task&, const std::string&, const std::string&);
std::string formatDuration (Task&, const std::string&);