[Core] Space sections better when saving config.

This commit is contained in:
gibbed 2020-04-13 12:23:49 -05:00 committed by Rick Gibbed
parent 37fbf39573
commit 7e2396f348
1 changed files with 7 additions and 0 deletions

View File

@ -85,17 +85,23 @@ void SaveConfig() {
// we use our own write logic because cpptoml doesn't // we use our own write logic because cpptoml doesn't
// allow us to specify comments :( // allow us to specify comments :(
std::string last_category; std::string last_category;
bool last_multiline_description = false;
xe::StringBuffer sb; xe::StringBuffer sb;
for (auto config_var : vars) { for (auto config_var : vars) {
if (config_var->is_transient()) { if (config_var->is_transient()) {
continue; continue;
} }
if (last_category != config_var->category()) { if (last_category != config_var->category()) {
if (!last_category.empty()) { if (!last_category.empty()) {
sb.Append('\n', 2); sb.Append('\n', 2);
} }
last_category = config_var->category(); last_category = config_var->category();
last_multiline_description = false;
sb.AppendFormat("[{}]\n", last_category); sb.AppendFormat("[{}]\n", last_category);
} else if (last_multiline_description) {
last_multiline_description = false;
sb.Append('\n');
} }
auto value = config_var->config_value(); auto value = config_var->config_value();
@ -138,6 +144,7 @@ void SaveConfig() {
sb.Append(*it); sb.Append(*it);
sb.Append('\n'); sb.Append('\n');
} }
last_multiline_description = true;
} }
} }
} }