Fix fill wrapping when text starts with whitespace (#1666)
parent
d608b7ba28
commit
4083d92ad1
|
@ -3585,6 +3585,11 @@ function printJSXElement(path, options, print) {
|
|||
multilineChildren.push(rawJsxWhitespace);
|
||||
return;
|
||||
} else if (i === 0) {
|
||||
// Fill expects alternating content & whitespace parts
|
||||
// always starting with content.
|
||||
// So we add a dummy content element if we would otherwise start
|
||||
// with whitespace.
|
||||
multilineChildren.push("");
|
||||
multilineChildren.push(concat([rawJsxWhitespace, hardline]));
|
||||
return;
|
||||
} else if (i === children.length - 1) {
|
||||
|
|
|
@ -96,6 +96,12 @@ x =
|
|||
Second
|
||||
</div> Third
|
||||
</div>
|
||||
|
||||
leading_whitespace =
|
||||
<div> First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth</div>
|
||||
|
||||
no_leading_whitespace =
|
||||
<div>First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth</div>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Wrapping text
|
||||
x = (
|
||||
|
@ -241,4 +247,19 @@ x = (
|
|||
</div>
|
||||
);
|
||||
|
||||
leading_whitespace = (
|
||||
<div>
|
||||
{" "}
|
||||
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh
|
||||
Twelfth Thirteenth Fourteenth
|
||||
</div>
|
||||
);
|
||||
|
||||
no_leading_whitespace = (
|
||||
<div>
|
||||
First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh
|
||||
Twelfth Thirteenth Fourteenth
|
||||
</div>
|
||||
);
|
||||
|
||||
`;
|
||||
|
|
|
@ -93,3 +93,9 @@ x =
|
|||
Second
|
||||
</div> Third
|
||||
</div>
|
||||
|
||||
leading_whitespace =
|
||||
<div> First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth</div>
|
||||
|
||||
no_leading_whitespace =
|
||||
<div>First Second Third Fourth Fifth Sixth Seventh Eighth Ninth Tenth Eleventh Twelfth Thirteenth Fourteenth</div>
|
||||
|
|
Loading…
Reference in New Issue