diff options
-rw-r--r-- | mesonbuild/mformat.py | 4 | ||||
-rw-r--r-- | test cases/format/1 default/indentation.meson | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/mesonbuild/mformat.py b/mesonbuild/mformat.py index 5e37019..e20e458 100644 --- a/mesonbuild/mformat.py +++ b/mesonbuild/mformat.py @@ -458,10 +458,10 @@ class TrimWhitespaces(FullAstVisitor): super().visit_IfClauseNode(node) self.move_whitespaces(node.endif, node) + for if_node in node.ifs: + if_node.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) diff --git a/test cases/format/1 default/indentation.meson b/test cases/format/1 default/indentation.meson index 31a809a..b1edc3a 100644 --- a/test cases/format/1 default/indentation.meson +++ b/test cases/format/1 default/indentation.meson @@ -69,5 +69,9 @@ if meson.project_version().version_compare('>1.2') ], } endforeach + elif 42 in d + d += {'foo': 43} + else # ensure else is correctly indented (issue #13316) + k = 'k' endif endif |