summaryrefslogtreecommitdiff
path: root/mesonbuild/mformat.py
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2025-10-06 09:47:54 -0400
committerDylan Baker <dylan@pnwbakers.com>2025-10-08 08:38:48 -0700
commit8d69552dbd61144cdeab4ac93137db672c62fd52 (patch)
tree4a5d9aab7181ebed512aae9216802ee20faa3e11 /mesonbuild/mformat.py
parent2379d727daaa5af8062cc12bbafcf44bdb6d1925 (diff)
downloadmeson-8d69552dbd61144cdeab4ac93137db672c62fd52.tar.gz
format: fix indentation at beginning of arguments
Fixes #14998
Diffstat (limited to 'mesonbuild/mformat.py')
-rw-r--r--mesonbuild/mformat.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/mesonbuild/mformat.py b/mesonbuild/mformat.py
index 184a9d31f..ac36dc08b 100644
--- a/mesonbuild/mformat.py
+++ b/mesonbuild/mformat.py
@@ -359,6 +359,7 @@ class TrimWhitespaces(FullAstVisitor):
super().visit_SymbolNode(node)
if node.value in "([{" and node.whitespaces.value == '\n':
node.whitespaces.value = ''
+ node.whitespaces.accept(self)
def visit_StringNode(self, node: mparser.StringNode) -> None:
self.enter_node(node)
@@ -599,8 +600,8 @@ class ArgumentFormatter(FullAstVisitor):
if not node.whitespaces.value or node.whitespaces.value == ' ':
node.whitespaces.value = '\n'
indent_by = (node.condition_level + indent) * self.config.indent_by
- if indent_by and node.whitespaces.value.endswith('\n'):
- node.whitespaces.value += indent_by
+ if indent_by:
+ node.whitespaces.value = re.sub(rf'\n({self.config.indent_by})*', '\n' + indent_by, node.whitespaces.value)
def visit_ArrayNode(self, node: mparser.ArrayNode) -> None:
self.enter_node(node)