Improve rendering of config

This commit is contained in:
CmdrKittens
2020-04-09 01:04:53 -04:00
parent 9a8538b844
commit 6d95eadf78
2 changed files with 1 additions and 14 deletions
@@ -80,11 +80,6 @@ abstract class ConfigString extends AbstractConfigValue implements Serializable
@Override @Override
protected void render(StringBuilder sb, int indent, boolean atRoot, ConfigRenderOptions options) { protected void render(StringBuilder sb, int indent, boolean atRoot, ConfigRenderOptions options) {
String rendered; sb.append(ConfigImplUtil.renderJsonString(value));
if (options.getJson())
rendered = ConfigImplUtil.renderJsonString(value);
else
rendered = ConfigImplUtil.renderStringUnquotedIfPossible(value);
sb.append(rendered);
} }
} }
@@ -209,9 +209,7 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
sb.append("["); sb.append("[");
if (options.getFormatted()) if (options.getFormatted())
sb.append('\n'); sb.append('\n');
int count = 0;
for (AbstractConfigValue v : value) { for (AbstractConfigValue v : value) {
count++;
if (options.getOriginComments()) { if (options.getOriginComments()) {
String[] lines = v.origin().description().split("\n"); String[] lines = v.origin().description().split("\n");
for (String l : lines) { for (String l : lines) {
@@ -224,12 +222,6 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
} }
} }
if (options.getComments()) { if (options.getComments()) {
if (count > 1) {
sb.append('\n');
if (!v.origin().comments().isEmpty()) {
sb.append('\n');
}
}
for (String comment : v.origin().comments()) { for (String comment : v.origin().comments()) {
indent(sb, indent + 1, options); indent(sb, indent + 1, options);
sb.append("# "); sb.append("# ");