Skip to content

Commit d13c321

Browse files
fables-talesclaude
andauthored
fix #413 (#795)
* fix #413 * Use let-chains to avoid expect() Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e102695 commit d13c321

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Rails.application.configure do
2+
3+
4+
# Raises error for missing translations.
5+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Rails.application.configure do
2+
# Raises error for missing translations.
3+
end

librubyfmt/src/parser_state.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,19 +475,19 @@ impl<'src> ParserState<'src> {
475475
.unwrap_or(true)
476476
};
477477
while should_iter(self, self.current_orig_line_number) {
478+
// If the next line is empty (no comment, no Ruby code), and we have
479+
// actual comment content accumulated, add a blank line to preserve
480+
// the visual gap between comment groups.
478481
if !self
479482
.comments_hash
480483
.has_line(self.current_orig_line_number + 1)
481484
&& self
482485
.comments_hash
483486
.is_empty_line(self.current_orig_line_number + 1)
484-
&& self.comments_to_insert.is_some()
487+
&& let Some(comments) = self.comments_to_insert.as_mut()
488+
&& comments.line_count() > 0
485489
{
486-
let mr = self.comments_to_insert.as_mut().expect("it's not nil");
487-
if mr.line_count() == 0 {
488-
break;
489-
}
490-
mr.add_line("".to_string());
490+
comments.add_line("".to_string());
491491
}
492492
self.on_line(self.current_orig_line_number + 1);
493493
}

0 commit comments

Comments
 (0)