Browse Source

fix(patch): preserve whitespace

and overflow-x which is better for slightly larger lines than
the viewing width which is more common
master
DanConwayDev 2 years ago
parent
commit
60729dfcdf
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 9
      src/lib/components/events/content/Patch.svelte

9
src/lib/components/events/content/Patch.svelte

@ -91,6 +91,7 @@
{#if expand_files[index]} {#if expand_files[index]}
<div class="border-t-1 border-base-300"> <div class="border-t-1 border-base-300">
{#each file.chunks as chunk, index} {#each file.chunks as chunk, index}
<div class="overflow-x-auto">
{#if index !== 0} {#if index !== 0}
<div class="text-middle h-6 bg-base-200 font-mono text-xs"> <div class="text-middle h-6 bg-base-200 font-mono text-xs">
<div <div
@ -101,7 +102,7 @@
</div> </div>
{/if} {/if}
{#each chunk.changes as change, i} {#each chunk.changes as change, i}
<div class="flex bg-base-100 font-mono text-xs"> <div class="flex w-full bg-base-100 font-mono text-xs">
<div <div
class="w-8 flex-none select-none {change.type == 'add' class="w-8 flex-none select-none {change.type == 'add'
? 'bg-success/30' ? 'bg-success/30'
@ -116,7 +117,7 @@
: extractChangeLine(change)} : extractChangeLine(change)}
</div> </div>
<div <div
class="text-wrap flex-grow break-all {change.type == 'add' class="w-full flex-grow whitespace-pre {change.type == 'add'
? 'bg-success/10' ? 'bg-success/10'
: change.type == 'del' : change.type == 'del'
? 'bg-error/10' ? 'bg-error/10'
@ -128,12 +129,14 @@
? change.content ? change.content
: change.content.substring(1), : change.content.substring(1),
{ {
language: (file.to || file.from)?.split('.').pop() || '', language:
(file.to || file.from)?.split('.').pop() || '',
} }
).value} ).value}
</div> </div>
</div> </div>
{/each} {/each}
</div>
{/each} {/each}
</div> </div>
{/if} {/if}

Loading…
Cancel
Save