Skip to content

Commit 0188454

Browse files
bruchar1eli-schwartz
authored andcommitted
mformat: force multiline arguments with comma
Force multiline arguments when there is a trailing comma. This is the behavior of muon. Fixes #14721.
1 parent 70b0de4 commit 0188454

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mesonbuild/mformat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ def visit_ArgumentNode(self, node: mparser.ArgumentNode) -> None:
242242
if node.is_multiline:
243243
self.is_multiline = True
244244

245+
nargs = len(node)
246+
if nargs and nargs == len(node.commas):
247+
self.is_multiline = True
248+
245249
if self.is_multiline:
246250
return
247251

test cases/format/1 default/indentation.meson

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,11 @@ if meson.project_version().version_compare('>1.2')
9292
# comment
9393
endif
9494
endif
95+
96+
# Test for trailing comma:
97+
m = [1, 2, 3]
98+
n = [
99+
1,
100+
2,
101+
3,
102+
]

0 commit comments

Comments
 (0)