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);
|
multilineChildren.push(rawJsxWhitespace);
|
||||||
return;
|
return;
|
||||||
} else if (i === 0) {
|
} 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]));
|
multilineChildren.push(concat([rawJsxWhitespace, hardline]));
|
||||||
return;
|
return;
|
||||||
} else if (i === children.length - 1) {
|
} else if (i === children.length - 1) {
|
||||||
|
|
|
@ -96,6 +96,12 @@ x =
|
||||||
Second
|
Second
|
||||||
</div> Third
|
</div> Third
|
||||||
</div>
|
</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
|
// Wrapping text
|
||||||
x = (
|
x = (
|
||||||
|
@ -241,4 +247,19 @@ x = (
|
||||||
</div>
|
</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
|
Second
|
||||||
</div> Third
|
</div> Third
|
||||||
</div>
|
</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