Skip to content

Commit 7a5767e

Browse files
author
Declan Vong
authored
fix: prevent jsx children wrapping in newlines when not necessary (#311)
1 parent 3f17d0d commit 7a5767e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/parsing/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7798,6 +7798,10 @@ fn parse_jsx_children<'a>(opts: ParseJsxChildrenOptions<'a>, context: &mut Conte
77987798
return Some(true);
77997799
}
78007800

7801+
// clear the end info when the start info changes
7802+
if condition_context.has_info_moved(&parent_start_info)? {
7803+
condition_context.clear_info(&parent_end_info);
7804+
}
78017805
// use newlines if the entire jsx element is on multiple lines
78027806
condition_resolvers::is_multiple_lines(condition_context, &parent_start_info, &parent_end_info)
78037807
},

tests/specs/issues/issue0310.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
~~ lineWidth: 50 ~~
2+
== should not require double format ==
3+
const thisLengthMatters = () => (
4+
<div prop={soDoesThisOneToo}>
5+
<SomeComponent>{someVar}</SomeComponent>
6+
</div>
7+
);
8+
9+
[expect]
10+
const thisLengthMatters = () => (
11+
<div prop={soDoesThisOneToo}>
12+
<SomeComponent>{someVar}</SomeComponent>
13+
</div>
14+
);

0 commit comments

Comments
 (0)