From a6b1a8913b32cbe6745862ea640ecfd1ba2a046b Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Thu, 1 Jan 2026 21:38:15 +0100 Subject: [PATCH] refactor: group replace pairs in script diffs --- .../entries/normalized-diff.blade.php | 99 +++++++++++-------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/resources/views/filament/infolists/entries/normalized-diff.blade.php b/resources/views/filament/infolists/entries/normalized-diff.blade.php index 844df9d..aceaaa5 100644 --- a/resources/views/filament/infolists/entries/normalized-diff.blade.php +++ b/resources/views/filament/infolists/entries/normalized-diff.blade.php @@ -253,56 +253,71 @@
{{ (string) $name }}
-
- From - @if ($isScriptContent || $isExpandable($from)) + + @if ($isScriptContent) +
+ Diff
View - @if ($isScriptContent) -
-@foreach ($ops as $op)
-@if ($op['type'] === 'equal')
+
+                                                            
+ @php + $count = count($ops); + @endphp + + @for ($i = 0; $i < $count; $i++) + @php + $op = $ops[$i]; + $next = $ops[$i + 1] ?? null; + @endphp + + @if ($op['type'] === 'equal') {{ $op['line'] }} -@elseif ($op['type'] === 'delete') + @elseif ($op['type'] === 'delete' && is_array($next) && ($next['type'] ?? null) === 'insert') - {{ $op['line'] }} -@endif -@endforeach -
- @else -
{{ $fromText }}
- @endif -
- @else -
{{ $fromText }}
- @endif -
-
- To - @if ($isScriptContent || $isExpandable($to)) -
- - View - - @if ($isScriptContent) -
-@foreach ($ops as $op)
-@if ($op['type'] === 'equal')
-{{ $op['line'] }}
-@elseif ($op['type'] === 'insert')
++ {{ $next['line'] }}
+                                                                        @php
+                                                                            $i++;
+                                                                        @endphp
+                                                                    @elseif ($op['type'] === 'delete')
+- {{ $op['line'] }}
+                                                                    @elseif ($op['type'] === 'insert')
 + {{ $op['line'] }}
-@endif
-@endforeach
-                                                                
- @else -
{{ $toText }}
- @endif + @endif + @endfor +
- @else -
{{ $toText }}
- @endif -
+ + @else +
+ From + @if ($isExpandable($from)) +
+ + View + +
{{ $fromText }}
+
+ @else +
{{ $fromText }}
+ @endif +
+
+ To + @if ($isExpandable($to)) +
+ + View + +
{{ $toText }}
+
+ @else +
{{ $toText }}
+ @endif +
+ @endif @else @php