From 3ecc3c7735372bca39b12293dc15d7f2e696f571 Mon Sep 17 00:00:00 2001 From: Jhoan Buitrago Date: Sat, 8 Aug 2026 21:32:48 -0500 Subject: [PATCH 1/3] test: add failing test --- tests/expected/comment_edge_cases.gd | 17 +++++++++++++++++ tests/input/comment_edge_cases.gd | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/expected/comment_edge_cases.gd b/tests/expected/comment_edge_cases.gd index e2fcc69..e5d5a6e 100644 --- a/tests/expected/comment_edge_cases.gd +++ b/tests/expected/comment_edge_cases.gd @@ -26,3 +26,20 @@ func test3(): else: pass + + +func test_inline_comment_preserves_blank_line(): + some_call() # inline comment + + another_call() + + +func test_inline_comment_no_blank_line(): + some_call() # inline comment + another_call() + + +func test_inline_comment_multiple_blank_lines_collapse(): + some_call() # inline comment + + another_call() diff --git a/tests/input/comment_edge_cases.gd b/tests/input/comment_edge_cases.gd index 4e19379..4d17714 100644 --- a/tests/input/comment_edge_cases.gd +++ b/tests/input/comment_edge_cases.gd @@ -26,3 +26,20 @@ func test3(): else: pass + +func test_inline_comment_preserves_blank_line(): + some_call() # inline comment + + another_call() + + +func test_inline_comment_no_blank_line(): + some_call() # inline comment + another_call() + + +func test_inline_comment_multiple_blank_lines_collapse(): + some_call() # inline comment + + + another_call() From 2dc8eaebcb9aee7632029acb02e6e61f285b73db Mon Sep 17 00:00:00 2001 From: Jhoan Buitrago Date: Sat, 8 Aug 2026 21:35:15 -0500 Subject: [PATCH 2/3] fix: preserve new line if there is an inline comment --- src/formatter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/formatter.rs b/src/formatter.rs index 77cee6f..47acce0 100644 --- a/src/formatter.rs +++ b/src/formatter.rs @@ -744,7 +744,7 @@ fn process_body( false, ); } - } else if statement_has_inline_comment && current_is_declaration { + } else if statement_has_inline_comment { let needs_two_blank_lines = needs_two_blank_lines(current_child_kind); add_spacing_between_body_children( previous_end, From 7b9376cc00c3196c45aa61cf244365714e0cb71b Mon Sep 17 00:00:00 2001 From: Nathan Lovato <12694995+NathanLovato@users.noreply.github.com> Date: Sun, 9 Aug 2026 15:03:56 +0200 Subject: [PATCH 3/3] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a92e98b..5df9be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This file documents the changes made to the formatter with each release. - Fixed an extra comma being inserted after a trailing comment in a lambda function argument (#304) - fixed certain export annotations being moved out of their respective groups (#308) - Preserve up to one blank line used to group elements in "containers" like enums +- Fixed losing blank line between statements in a body if the previous statement has an inline comment (#320, thanks @Buitragox for the fix) ## Release 0.24.0 (2026-07-25)