Skip to content

Commit

Permalink
Merge branch 'main' into allow-formatting-pipelines-inline
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Aug 25, 2024
2 parents ec29b1d + 03321b3 commit f1c37cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,13 @@ test("long arg as last arg", () => {
expect(src).toBeFormatted();
});

test("long arg as last arg", () => {
const src = `let x = a_super_long_function_that_wraps_but_does_not_have_space_to_wrap_a_super_long()
`;

expect(src).toBeFormatted();
});

test("let inside list", () => {
const src = `let x = [
{
Expand Down
7 changes: 5 additions & 2 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ function exprToDoc(ast: UntypedExpr, block: boolean): Doc {
ast.caller.type === "identifier" &&
isTupleN(ast.caller.namespace, ast.caller.name);

return nextBreakFits(
if (ast.args.length === 0) {
return concat(exprToDoc(ast.caller, false), text("()"));
}

return broken(
group(
isTuple ? nil : exprToDoc(ast.caller, false),
text("("),
Expand All @@ -345,7 +349,6 @@ function exprToDoc(ast: UntypedExpr, block: boolean): Doc {
break_("", ","),
text(")"),
),
false,
);
}

Expand Down

0 comments on commit f1c37cd

Please sign in to comment.