The PHP code in these blocks is indented to the same level and I would expect it to be formatted identically. In particular, the second statement (the ternary) fits into 79 chars, including indentation, and it should be left on a single line.
I can reproduce 1-token-per-line wrapping that @calebdw is seeing, but only after smashing that PHP into so many ifs that every line exceeds the wrap limit (see below). This strongly suggests that we're telling prettier to format these to the wrong printWidth, because it's treating everyline line it's already exceeded the print width.
I can look into this, but it will be a few days.
Reproduction snippet with extreme wrapping
@php
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
if (1) {
$percent =
$item[
'historical'
] ??
null
? round(
(100 *
($item[
'today'
] -
$item[
'historical'
])) /
$item[
'historical'
],
)
: null;
$color =
$percent <
0
? '#8b0000'
: '#006400';
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
@endphp
Version
1.41.0
Template before formatting
Template after formatting
Expected Behaviour
This code was reported by @calebdw at https://github.com/shufo/blade-formatter/pull/909#issuecomment-1961581690, and I've reproduced it here.
The PHP code in these blocks is indented to the same level and I would expect it to be formatted identically. In particular, the second statement (the ternary) fits into 79 chars, including indentation, and it should be left on a single line.
I can reproduce 1-token-per-line wrapping that @calebdw is seeing, but only after smashing that PHP into so many
if
s that every line exceeds the wrap limit (see below). This strongly suggests that we're telling prettier to format these to the wrongprintWidth
, because it's treating everyline line it's already exceeded the print width.I can look into this, but it will be a few days.
Reproduction snippet with extreme wrapping
Relevant log output
No response