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:
@@ -80,8 +80,9 @@ bool CmdConfig::setConfigVariable (
|
|||||||
{
|
{
|
||||||
auto new_line = line.substr (0, pos + name.length () + 1) + json::encode (value);
|
auto new_line = line.substr (0, pos + name.length () + 1) + json::encode (value);
|
||||||
|
|
||||||
|
// Preserve the comment
|
||||||
if (comment != std::string::npos)
|
if (comment != std::string::npos)
|
||||||
line += ' ' + line.substr (comment);
|
new_line += " " + line.substr (comment);
|
||||||
|
|
||||||
// Rewrite the line
|
// Rewrite the line
|
||||||
line = new_line;
|
line = new_line;
|
||||||
|
|||||||
Reference in New Issue
Block a user