Skip to content

Commit dd320d7

Browse files
author
Michael Bryan
committed
Added a test to make sure subsequent entries with a comment aren't separated by newlines
1 parent bf41121 commit dd320d7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

fluent-syntax/src/serializer.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl Serializer {
5252
match entry {
5353
Entry::Message(msg) => self.serialize_message(msg),
5454
Entry::Comment(comment) => {
55+
if self.state.has_entries {
56+
self.writer.newline();
57+
}
58+
5559
self.serialize_comment(comment)?;
5660
self.writer.newline();
5761
Ok(())
@@ -71,10 +75,6 @@ impl Serializer {
7175
Comment::ResourceComment { content } => ("###", content),
7276
};
7377

74-
if self.state.has_entries {
75-
self.writer.newline();
76-
}
77-
7878
for line in lines {
7979
self.writer.write_literal(prefix)?;
8080

@@ -480,6 +480,10 @@ mod serialize_resource_tests {
480480
message_comment,
481481
"# A multiline\n# message comment.\nfoo = Foo\n",
482482
);
483+
round_trip_test!(
484+
dont_prefix_a_subsequent_entry_comment_with_a_newline,
485+
"first = Firstsubsequent_ Comment\nfoo = Foo\n",
486+
);
483487
round_trip_test!(
484488
group_comment,
485489
"## Comment Header\n##\n## A multiline\n## group comment.\n\nfoo = Foo\n",

0 commit comments

Comments
 (0)