Skip to content

Commit

Permalink
Correctly format multiple function calls in expression
Browse files Browse the repository at this point in the history
Closes #69.
  • Loading branch information
bbannier committed Jan 16, 2024
1 parent f3fd339 commit ef43ea6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ def test_format_comment_separator(self):
self._format(code.encode()).decode().splitlines(), expected.splitlines()
)

def test_multiple_function_calls(self):
"""Validates correct line break when a expression with function calls
need to be broken. This is a regression test for #69."""
code = "f(x) " + "+ f(x)" * 20 + ";"
formatted = self._format(code.encode()).decode()
self.assertTrue(
formatted.splitlines()[0].endswith("("),
"expression should not break function calls across lines",
)


class TestFormattingErrors(unittest.TestCase):
def _format(self, content):
Expand Down
2 changes: 1 addition & 1 deletion tree-sitter-zeek

0 comments on commit ef43ea6

Please sign in to comment.