Skip to content

Commit 4a8254a

Browse files
olehermanseclaude
andcommitted
cfengine format: Fixed indentation of comments inside empty blocks
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
1 parent 689ac43 commit 4a8254a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/cfengine_cli/format.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
BLOCK_TYPES = {"bundle_block", "promise_block", "body_block"}
2727

28+
BLOCK_BODY_TYPES = {"bundle_block_body", "promise_block_body", "body_block_body"}
29+
2830
PROMISER_PARTS = {"promiser", "->", "stakeholder"}
2931

3032

@@ -643,6 +645,10 @@ def _comment_indent(node: Node, indent: int) -> int:
643645
nearest = _skip_comments(node.prev_named_sibling, "prev")
644646
if nearest and nearest.type in INDENTED_TYPES:
645647
return indent + 2
648+
# No indented sibling found — if we're directly inside a block body,
649+
# indent so the comment lines up with where promises/attributes would.
650+
if nearest is None and node.parent and node.parent.type in BLOCK_BODY_TYPES:
651+
return indent + 2
646652
return indent
647653

648654

0 commit comments

Comments
 (0)