File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change @@ -5417,4 +5417,54 @@ describe('formatter', () => {
5417
5417
5418
5418
await util . doubleFormatCheck ( content , expected ) ;
5419
5419
} ) ;
5420
+
5421
+ test ( '@php blocks respect indent level for deeply indented code (issue #915)' , async ( ) => {
5422
+ let content = [
5423
+ '<div>' ,
5424
+ '<div>' ,
5425
+ '<div>' ,
5426
+ '<div>' ,
5427
+ '<div>' ,
5428
+ '<div>' ,
5429
+ '@php' ,
5430
+ "$percent = $item['historical'] ?? null ? round((100 * ($item['today'] - $item['historical'])) / $item['historical']) : null;" ,
5431
+ '' ,
5432
+ "$color = $percent < 0 ? '#8b0000' : '#006400';" ,
5433
+ '@endphp' ,
5434
+ '</div>' ,
5435
+ '</div>' ,
5436
+ '</div>' ,
5437
+ '</div>' ,
5438
+ '</div>' ,
5439
+ '</div>' ,
5440
+ ] . join ( '\n' ) ;
5441
+
5442
+ // this is slightly different than the code presented in #915 because that
5443
+ // code was wrapped to 80 columns, but these tests all use 120
5444
+ let expected = [
5445
+ '<div>' ,
5446
+ ' <div>' ,
5447
+ ' <div>' ,
5448
+ ' <div>' ,
5449
+ ' <div>' ,
5450
+ ' <div>' ,
5451
+ ' @php' ,
5452
+ ' $percent =' ,
5453
+ " $item['historical'] ?? null" ,
5454
+ " ? round((100 * ($item['today'] - $item['historical'])) / $item['historical'])" ,
5455
+ ' : null;' ,
5456
+ '' ,
5457
+ " $color = $percent < 0 ? '#8b0000' : '#006400';" ,
5458
+ ' @endphp' ,
5459
+ ' </div>' ,
5460
+ ' </div>' ,
5461
+ ' </div>' ,
5462
+ ' </div>' ,
5463
+ ' </div>' ,
5464
+ '</div>' ,
5465
+ `` ,
5466
+ ] . join ( '\n' ) ;
5467
+
5468
+ await util . doubleFormatCheck ( content , expected ) ;
5469
+ } ) ;
5420
5470
} ) ;
Original file line number Diff line number Diff line change @@ -1301,8 +1301,7 @@ export default class Formatter {
1301
1301
} else if ( isMultipleStatements ) {
1302
1302
// multiple statments on mult lines
1303
1303
1304
- const indentLevel = ( indent . amount + 1 ) * this . indentSize ;
1305
-
1304
+ const indentLevel = indent . amount + this . indentSize ;
1306
1305
rawBlock = (
1307
1306
await util . formatStringAsPhp ( `<?php${ rawBlock } ?>` , {
1308
1307
...this . options ,
You can’t perform that action at this time.
0 commit comments