You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Trying from a fresh install to eliminate possible errors, tried both with ONLY the plugin and with the "Laravel Extension Pack")
Whenever I try to format on any blade file using laravel-blade-formatter, plugin goes into an endless loop and starts clogging any other actions. After the loop has started, any saves on other files get severely slower. The formatting itself never happens.
EDIT
Found out after further restarts that this is happening in one particular file, triggering formatting on the attached code seems to break the plugin until the next VSCode restart.
`
<?php
// Build a calendar
// First day of this month, then monday of that week
$start = Carbon\Carbon::now()->startOfMonth()->startOfWeek();
// Last day of this month, then sunday of that week
$end = Carbon\Carbon::now()->endOfMonth()->endOfWeek();
$periods = [];
$period = [];
$day = $start->copy();
while ($day->lte($end)) {
$period[] = $day->copy();
if ($day->isSunday()) {
$periods[] = $period;
$period = [];
}
$day->addDay();
}
// Worker fetching
// TODO: Doesn't exist yet, faked for now
// Worker has [id, name, days => [date => [clockin, clockout], notes]]
$workerNames = ['Name1', 'Name2', 'Name3', 'Name4'];
$workers = [];
for ($i = 0; $i < 4; $i++) {
$worker = new stdClass();
$worker->id = $i;
$worker->name = $workerNames[$i];
$worker->days = [];
for ($j = 0; $j < rand(8, 10); $j++) {
// Random day between 0 and 31, trailing 0 if < 10 $day=rand(1, 31);
$day = $day < 10 ? '0' . $day : $day;
$worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' =>
'16:00', 'notes' => ''];
}
$workers[] = $worker;
}
?>
<div class="container">
<div class="grid w-full grid-cols-8 overflow-x-auto break-words bg-gray-200">
{{-- X axis = Days of the week, Y axis = row --}}
@foreach ($periods as $period)
{{-- Day headers --}}
<div class=""></div>
@foreach ($period as $day)
<div class="text-center bg-green-100 border border-gray-300">{{ $day->format('d/m') }}</div>
@endforeach
{{-- Worker rows --}}
@foreach ($workers as $worker)
{{-- If the $worker has no $worker->days matching any day in $period, continue --}}
@if (count(array_intersect_key($worker->days, array_flip(array_map(function ($day) { return
$day->format('Y-m-d'); }, $period)))) == 0)
@continue
@endif
<div class="border border-gray-300 bg-green-50">{{ $worker->name }}</div>
@foreach ($period as $day)
@if (isset($worker->days[$day->format('Y-m-d')]))
<div
class="relative flex flex-col font-mono text-center bg-white border border-gray-300 group md:flex-row md:place-content-between md:px-3">
{{-- Button for editting an entry for this day and worker --}}
<div
class="box-border absolute left-0 right-0 z-10 hidden w-full h-full bg-yellow-100 cursor-pointer group-hover:block opacity-60">
<button class="w-full h-full"
onclick="alert('Editant...\r\nHorari: 08:00 - 16:00\r\nNota:')">Editar</button>
</div>
{{-- Clockin --}}
<span>
{{ $worker->days[$day->format('Y-m-d')]['clockin'] }}
</span>
{{-- Clockout --}}
<span>
{{ $worker->days[$day->format('Y-m-d')]['clockout'] }}
</span>
{{-- Notes --}}
@if ($worker->days[$day->format('Y-m-d')]['notes'] != '')
<span class="hidden md:block">
{{ $worker->days[$day->format('Y-m-d')]['notes'] }}
</span>
@endif
</div>
@else
<div class="relative text-center bg-white border border-gray-300 group">
{{-- Button for adding an entry for this day and worker --}}
<div
class="box-border absolute left-0 right-0 z-10 hidden w-full h-full bg-green-100 cursor-pointer group-hover:block opacity-60">
<button class="w-full h-full" onclick="alert('Afegint entrada...')">+</button>
</div>
</div>
@endif
@endforeach
@endforeach
{{-- Row to add worker --}}
<div>
{{-- Worker select --}}
<select class="w-full h-full p-0.5 select select-xs">
<option value="0" selected disabled>Afegir treballador</option>
@foreach ($workers as $worker)
<option value="{{ $worker->id }}">{{ $worker->name }}</option>
@endforeach
</select>
</div>
@foreach ($period as $day)
<div class="relative text-center bg-gray-100 border border-gray-300 group opacity-60">
{{-- Button for adding an entry for this day and worker --}}
<div
class="box-border absolute left-0 right-0 z-10 hidden w-full h-full bg-green-100 cursor-pointer group-hover:block opacity-60">
<button class="w-full h-full" onclick="alert('Afegint entrada...')">+</button>
</div>
</div>
@endforeach
{{-- Spacer --}}
<div class="h-4 col-span-8"></div>
@endforeach
</div>
</div>
`
Expected Behavior
Code should be formatted as per laravel-blade-formatter's guidelines
Actual Behavior
Visual Studio Code breaks and gets stuck in an endless loop of being unable to format (nor save, if save on format was enabled)
Additional Context
version: 0.22.1
platform: Windows 10 (64-bit)
EDIT 2
Found out that a mix of the php blade tag, a comment with a hyphen, and the code attached seem to break the inner logic of the formatter which, when combined with other code, can escalate to an infinite loop? (since I'm failing at attaching code with formatting, posting an image too):
Code to reproduce
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Expected result
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Actual result
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Hyphen in / Hyphen out
The text was updated successfully, but these errors were encountered:
Description
(Trying from a fresh install to eliminate possible errors, tried both with ONLY the plugin and with the "Laravel Extension Pack")
Whenever I try to format on any blade file using laravel-blade-formatter, plugin goes into an endless loop and starts clogging any other actions. After the loop has started, any saves on other files get severely slower. The formatting itself never happens.
EDIT
Found out after further restarts that this is happening in one particular file, triggering formatting on the attached code seems to break the plugin until the next VSCode restart.
`
Expected Behavior
Code should be formatted as per laravel-blade-formatter's guidelines
Actual Behavior
Visual Studio Code breaks and gets stuck in an endless loop of being unable to format (nor save, if save on format was enabled)
Additional Context
version: 0.22.1
platform: Windows 10 (64-bit)
EDIT 2
Found out that a mix of the php blade tag, a comment with a hyphen, and the code attached seem to break the inner logic of the formatter which, when combined with other code, can escalate to an infinite loop? (since I'm failing at attaching code with formatting, posting an image too):
Code to reproduce
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Expected result
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Actual result
<x-app-layout> @php // TODO: A hyphen here ' breaks things $worker->days['2023-08-' . $day] = ['clockin' => '08:00', 'clockout' => '16:00', 'notes' => '']; @endphp </x-app-layout>
Hyphen in / Hyphen out
The text was updated successfully, but these errors were encountered: