diff options
-rw-r--r-- | mesonbuild/mformat.py | 5 | ||||
-rw-r--r-- | test cases/format/5 transform/default.expected.meson | 14 | ||||
-rw-r--r-- | test cases/format/5 transform/muon.expected.meson | 14 | ||||
-rw-r--r-- | test cases/format/5 transform/options.expected.meson | 14 | ||||
-rw-r--r-- | test cases/format/5 transform/source.meson | 14 |
5 files changed, 59 insertions, 2 deletions
diff --git a/mesonbuild/mformat.py b/mesonbuild/mformat.py index 92729a0..1e134f5 100644 --- a/mesonbuild/mformat.py +++ b/mesonbuild/mformat.py @@ -536,7 +536,7 @@ class TrimWhitespaces(FullAstVisitor): def visit_ParenthesizedNode(self, node: mparser.ParenthesizedNode) -> None: self.enter_node(node) - is_multiline = node.lpar.whitespaces and '#' in node.lpar.whitespaces.value + is_multiline = node.lpar.lineno != node.rpar.lineno if is_multiline: self.indent_comments += self.config.indent_by @@ -546,7 +546,8 @@ class TrimWhitespaces(FullAstVisitor): if is_multiline: node.inner.whitespaces.value = self.dedent(node.inner.whitespaces.value) self.indent_comments = self.dedent(self.indent_comments) - self.add_nl_after(node.inner) + if node.lpar.whitespaces and '\n' in node.lpar.whitespaces.value: + self.add_nl_after(node.inner) node.rpar.accept(self) self.move_whitespaces(node.rpar, node) diff --git a/test cases/format/5 transform/default.expected.meson b/test cases/format/5 transform/default.expected.meson index 18af2f8..4a9851a 100644 --- a/test cases/format/5 transform/default.expected.meson +++ b/test cases/format/5 transform/default.expected.meson @@ -36,6 +36,20 @@ a2 = [ # space array a3 = [1, 2, 3] +# multi line expression +is_foo = ( + true + and false + and true + and false + and true + and false + and true + and false + and true + and false +) + # no single comma function fct = files( 'meson.build', # force multiline diff --git a/test cases/format/5 transform/muon.expected.meson b/test cases/format/5 transform/muon.expected.meson index 0e6309c..3b61270 100644 --- a/test cases/format/5 transform/muon.expected.meson +++ b/test cases/format/5 transform/muon.expected.meson @@ -36,6 +36,20 @@ a2 = [ # space array a3 = [1, 2, 3] +# multi line expression +is_foo = ( + true + and false + and true + and false + and true + and false + and true + and false + and true + and false +) + # no single comma function fct = files( 'meson.build', # force multiline diff --git a/test cases/format/5 transform/options.expected.meson b/test cases/format/5 transform/options.expected.meson index 9ed6ac2..84917c1 100644 --- a/test cases/format/5 transform/options.expected.meson +++ b/test cases/format/5 transform/options.expected.meson @@ -14,6 +14,20 @@ a2 = [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 2 # space array a3 = [ 1, 2, 3 ] +# multi line expression +is_foo = ( + true + and false + and true + and false + and true + and false + and true + and false + and true + and false +) + # no single comma function fct = files( 'meson.build' # force multiline diff --git a/test cases/format/5 transform/source.meson b/test cases/format/5 transform/source.meson index 4482884..a3b326b 100644 --- a/test cases/format/5 transform/source.meson +++ b/test cases/format/5 transform/source.meson @@ -18,6 +18,20 @@ a2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 # space array a3 = [ 1, 2, 3 ] +# multi line expression +is_foo = ( + true + and false + and true + and false + and true + and false + and true + and false + and true + and false +) + # no single comma function fct = files( 'meson.build', # force multiline |