Skip to content

Commit

Permalink
Merge pull request #874 from shufo/fix/raw-php-block-unnecessary-spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo authored Oct 9, 2023
2 parents fd10f3e + a230be9 commit 724aff9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion __tests__/fixtures/formatted.raw_php_block.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@foreach ($users as $user)
@php
$users = $_GET;
foreach ($users as $key1 => $value) {
if (is_array($value)) {
foreach ($value as $key2 => $value2) {
Expand Down
26 changes: 26 additions & 0 deletions __tests__/fixtures/snapshots/php_block_directive.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
------------------------------------options----------------------------------------
{}
------------------------------------content----------------------------------------
@php
use Eagle\Utilities\Dates\TimeZone;
// assert blank line will not be indented

$timezone_options =
['' => ''] +
TimeZone::create()
->format('tz-label')
->countryCodePriority('US')
->get();
@endphp
------------------------------------expected----------------------------------------
@php
use Eagle\Utilities\Dates\TimeZone;
// assert blank line will not be indented

$timezone_options =
['' => ''] +
TimeZone::create()
->format('tz-label')
->countryCodePriority('US')
->get();
@endphp
4 changes: 4 additions & 0 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,10 @@ export default class Formatter {
return prefixForEnd + line;
}

if (line.length === 0) {
return line;
}

return prefix + line;
})
.join('\n')
Expand Down

0 comments on commit 724aff9

Please sign in to comment.