aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/mformat.py2
-rw-r--r--mesonbuild/mparser.py2
-rw-r--r--test cases/format/1 default/gh13242.meson4
-rw-r--r--test cases/format/1 default/meson.build3
4 files changed, 6 insertions, 5 deletions
diff --git a/mesonbuild/mformat.py b/mesonbuild/mformat.py
index e20e458..42f562e 100644
--- a/mesonbuild/mformat.py
+++ b/mesonbuild/mformat.py
@@ -744,7 +744,7 @@ class ComputeLineLengths(FullAstVisitor):
self.exit_node(node)
def split_if_needed(self, node: mparser.ArgumentNode) -> None:
- if not node.is_multiline and self.length > self.config.max_line_length:
+ if len(node) and not node.is_multiline and self.length > self.config.max_line_length:
arg = self.argument_stack[self.level] if len(self.argument_stack) > self.level else node
if not arg.is_multiline:
arg.is_multiline = True
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index ec08ccf..50d7203 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -377,7 +377,7 @@ class ArgumentNode(BaseNode):
return self.order_error
def __len__(self) -> int:
- return self.num_args() # Fixme
+ return self.num_args() + self.num_kwargs()
@dataclass(unsafe_hash=True)
class ArrayNode(BaseNode):
diff --git a/test cases/format/1 default/gh13242.meson b/test cases/format/1 default/gh13242.meson
index b9122ec..67f7dd1 100644
--- a/test cases/format/1 default/gh13242.meson
+++ b/test cases/format/1 default/gh13242.meson
@@ -10,9 +10,7 @@ test(
)
test(
- should_fail: (settings.get('x', false) and not settings['y'] and dep.version(
-
- ).version_compare(
+ should_fail: (settings.get('x', false) and not settings['y'] and dep.version().version_compare(
'>=1.2.3',
)),
)
diff --git a/test cases/format/1 default/meson.build b/test cases/format/1 default/meson.build
index 35e5b96..83ae19a 100644
--- a/test cases/format/1 default/meson.build
+++ b/test cases/format/1 default/meson.build
@@ -10,6 +10,9 @@ meson_files = {
'gh13242': files('gh13242.meson'),
}
+# Ensure empty function are formatted correctly on long lines
+a = '@0@@1@@2@@3@@4@'.format('one', 'two', 'three', 'four', 'five').strip().strip()
+
foreach name, f : meson_files
test(name, meson_cmd, args: ['format', '--check-only', f])
endforeach