Merge pull request #88 from typesafehub/havocp-comment-spaces

Don't add multiple spaces in front of comments, fixes #87
This commit is contained in:
Havoc Pennington 2013-09-19 09:50:44 -07:00
commit e85a54e4a1
2 changed files with 12 additions and 1 deletions

View File

@ -390,7 +390,9 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
if (options.getComments()) {
for (String comment : v.origin().comments()) {
indent(sb, indent + 1, options);
sb.append("# ");
sb.append("#");
if (!comment.startsWith(" "))
sb.append(' ');
sb.append(comment);
sb.append("\n");
}

View File

@ -1059,6 +1059,15 @@ class ConfigTest extends TestUtils {
throw e
}
}
// rendering repeatedly should not make the file different (e.g. shouldn't make it longer)
// unless the debug comments are in there
if (!renderOptions.getOriginComments()) {
val renderedAgain = resolvedParsed.root.render(renderOptions)
// TODO the strings should be THE SAME not just the same length,
// but there's a bug right now that sometimes object keys seem to
// be re-ordered. Need to fix.
assertEquals("render changed, resolved options=" + renderOptions, resolvedRender.length, renderedAgain.length)
}
}
}
}