Skip to content

Commit 808784e

Browse files
olehermanseclaude
andcommitted
cfengine format: Fixed case where removed empty comments would cause no empty line between bundles
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Ole Herman Schumacher Elgesem <[email protected]>
1 parent 4a8254a commit 808784e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/cfengine_cli/format.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ def _format_block_header(node: Node, fmt: Formatter) -> list[Node]:
561561
line = " ".join(header_parts)
562562
if not fmt.empty:
563563
prev_sib = node.prev_named_sibling
564+
# Skip over preceding empty comments since they will be removed
565+
while prev_sib and prev_sib.type == "comment" and _is_empty_comment(prev_sib):
566+
prev_sib = prev_sib.prev_named_sibling
564567
if not (prev_sib and prev_sib.type == "comment"):
565568
fmt.blank_line()
566569
fmt.print(line, 0)

0 commit comments

Comments
 (0)