Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,12 @@ fn should_skip_paren_expr<'a>(node: &'a ParenExpr<'a>, context: &Context<'a>) ->
return is_jsx_paren_expr_handled_node(node.expr.into(), context);
}

// keep when there is an explicit newline after the paren
let node_text = node.text_fast(context.program);
if !utils::has_no_new_lines_in_leading_whitespace(&node_text[1..]) {
return false;
}

if let Node::AssignExpr(assign_expr) = parent {
if assign_expr.right.range().contains(&node.range()) {
return true;
Expand Down
11 changes: 11 additions & 0 deletions tests/specs/issues/issue0519.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
== should keep parens when starting with an explicit newline ==
const mathResult = (
1 + 2);
const mathResult = (1 + 2
);

[expect]
const mathResult = (
1 + 2
);
const mathResult = 1 + 2;
Loading