CmdConfig: Properly preserve comments at the end of the line

Trailing comments previously caused crash of the application.

Closes #2581.
This commit is contained in:
Tomas Babej 2021-08-21 00:46:36 -04:00
parent e2e184b8d4
commit a464324617

View file

@ -80,8 +80,9 @@ bool CmdConfig::setConfigVariable (
{
auto new_line = line.substr (0, pos + name.length () + 1) + json::encode (value);
// Preserve the comment
if (comment != std::string::npos)
line += ' ' + line.substr (comment);
new_line += " " + line.substr (comment);
// Rewrite the line
line = new_line;