Skip to content

Commit da01dd7

Browse files
committed
fix(formatter): ignore the leading line break for the first argument of the call expression
1 parent 00d6498 commit da01dd7

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

crates/oxc_formatter/src/write/call_arguments.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ impl<'a> Format<'a> for AstNode<'a, ArenaVec<'a, Argument<'a>>> {
9696
);
9797
}
9898

99-
let has_empty_line =
100-
self.iter().any(|arg| f.source_text().get_lines_before(arg.span(), f.comments()) > 1);
99+
let has_empty_line = self
100+
.iter()
101+
.skip(1)
102+
.any(|arg| f.source_text().get_lines_before(arg.span(), f.comments()) > 1);
101103
if has_empty_line
102104
|| (!matches!(self.parent.parent(), AstNodes::Decorator(_))
103105
&& is_function_composition_args(self))
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
gen
2+
3+
("a");
4+
5+
gen
6+
7+
(
8+
9+
"b");
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
source: crates/oxc_formatter/tests/fixtures/mod.rs
3+
---
4+
==================== Input ====================
5+
gen
6+
7+
("a");
8+
9+
gen
10+
11+
(
12+
13+
"b");
14+
==================== Output ====================
15+
gen("a");
16+
17+
gen("b");
18+
19+
===================== End =====================

0 commit comments

Comments
 (0)