Skip to content

Commit

Permalink
mformat: fix else token not correctly indented
Browse files Browse the repository at this point in the history
  • Loading branch information
bruchar1 committed Jun 12, 2024
1 parent 0352c90 commit 134cc8a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions mesonbuild/mformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,9 @@ def visit_IfClauseNode(self, node: mparser.IfClauseNode) -> None:
super().visit_IfClauseNode(node)
self.move_whitespaces(node.endif, node)

node.ifs[-1].whitespaces.value += node.condition_level * self.config.indent_by
if isinstance(node.elseblock, mparser.ElseNode):
node.elseblock.whitespaces.value += node.condition_level * self.config.indent_by
else:
node.ifs[-1].whitespaces.value += node.condition_level * self.config.indent_by

def visit_IfNode(self, node: mparser.IfNode) -> None:
super().visit_IfNode(node)
Expand Down
2 changes: 2 additions & 0 deletions test cases/format/1 default/indentation.meson
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ if meson.project_version().version_compare('>1.2')
],
}
endforeach
else # ensure else is correctly indented (issue #13316)
k = 'k'
endif
endif

0 comments on commit 134cc8a

Please sign in to comment.