Make compare more compact and add line numbers

This commit is contained in:
Tim
2025-04-24 18:23:57 +02:00
parent d7e558cae9
commit ced70fd650
2 changed files with 8 additions and 11 deletions

View File

@ -187,6 +187,7 @@ class MyersDiff
case DiffTypeEnum::KEEP->value:
for ($i = 0; $i < $data; $i++) {
$lines[] = [
'line' => $x,
'type' => 'keep',
'from' => $a[$x],
'to' => $a[$x],
@ -197,6 +198,7 @@ class MyersDiff
case DiffTypeEnum::DELETE->value:
for ($i = 0; $i < $data; $i++) {
$lines[] = [
'line' => $x,
'type' => 'delete',
'from' => $a[$x],
'to' => '',
@ -207,6 +209,7 @@ class MyersDiff
case DiffTypeEnum::INSERT->value:
foreach ($data as $v) {
$lines[] = [
'line' => $x,
'type' => 'insert',
'from' => '',
'to' => $v,

View File

@ -7,10 +7,11 @@
<i class="fa fa-arrow-left"></i> Back
</a>
<br><br>
<table class="table table-condensed table-hover">
<table class="table table-sm table-hover">
<thead>
<tr>
<th>Line</th>
<th>Type</th>
<th>Old</th>
<th>New</th>
</tr>
@ -18,19 +19,12 @@
<tbody>
{% for line in diff %}
<tr>
<td>{{ line.line }}.</td>
<td class="table-{{ line.type == 'insert' ? 'success' : (line.type == 'delete' ? 'danger' : 'info') }}">
{{ line.type }}
</td>
<td>
{% if line.from %}
{{ line.from }}
{% endif %}
</td>
<td>
{% if line.to %}
{{ line.to }}
{% endif %}
</td>
<td>{{ line.from }}</td>
<td>{{ line.to }}</td>
</tr>
{% endfor %}
</tbody>