InputCommon: fix serialization of control expression with line breaks

The control expression editor allows line breaks, but the serialization was
losing anything after the first line break (/r /n).
Instead of opting to encode them and decode them on serialization
(which I tried but was not safe, as it would lose /n written in the string by users),
I opted to replace them with a space.
This commit is contained in:
Filoppi
2021-05-11 16:30:29 +03:00
parent eb5cd9be78
commit 574477866f
4 changed files with 25 additions and 4 deletions

View File

@ -113,9 +113,16 @@ public:
void SaveToIni(IniFile::Section& section, const std::string& group_name) const override
{
if (IsSimpleValue())
{
section.Set(group_name + m_details.ini_name, GetValue(), m_default_value);
}
else
section.Set(group_name + m_details.ini_name, m_value.m_input.GetExpression(), "");
{
// We can't save line breaks in a single line config. Restoring them is too complicated.
std::string expression = m_value.m_input.GetExpression();
ReplaceBreaksWithSpaces(expression);
section.Set(group_name + m_details.ini_name, expression, "");
}
}
bool IsSimpleValue() const override { return m_value.IsSimpleValue(); }