Skip to content

Commit 57e8828

Browse files
committed
Improve newline handling for comments
1 parent a454dc4 commit 57e8828

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

format/yaml/src/main/java/org/spongepowered/configurate/yaml/YamlParserComposer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ void applyComments(final ConfigurationNode node) {
284284
= (CommentedConfigurationNodeIntermediary<? extends @NonNull Object>) node;
285285
if (commented.comment() != null) {
286286
collector.insert(0, commented.comment());
287-
collector.insert(commented.comment().length(), '\n');
287+
if (collector.charAt(collector.length() - 1) != '\n') {
288+
collector.insert(commented.comment().length(), '\n');
289+
}
288290
}
289291
commented.comment(collector.toString());
290292
collector.delete(0, collector.length());

0 commit comments

Comments
 (0)