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. 85
      src/lib/components/events/content/Patch.svelte

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

@ -91,49 +91,52 @@
{#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}
{#if index !== 0} <div class="overflow-x-auto">
<div class="text-middle h-6 bg-base-200 font-mono text-xs"> {#if index !== 0}
<div <div class="text-middle h-6 bg-base-200 font-mono text-xs">
class="w-8 flex-none select-none pr-2 text-right opacity-50" <div
> class="w-8 flex-none select-none pr-2 text-right opacity-50"
... >
...
</div>
</div> </div>
</div> {/if}
{/if} {#each chunk.changes as change, i}
{#each chunk.changes as change, i} <div class="flex w-full bg-base-100 font-mono text-xs">
<div class="flex 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' : change.type == 'del'
: change.type == 'del' ? 'bg-error/30'
? 'bg-error/30' : 'bg-slate-500/20'} pr-2 text-right opacity-50"
: 'bg-slate-500/20'} pr-2 text-right opacity-50" >
> {isAddChange(change) &&
{isAddChange(change) && i !== 0 &&
i !== 0 && isDeleteChange(chunk.changes[i - 1])
isDeleteChange(chunk.changes[i - 1]) ? ''
? '' : extractChangeLine(change)}
: extractChangeLine(change)} </div>
</div> <div
<div class="w-full flex-grow whitespace-pre {change.type == 'add'
class="text-wrap flex-grow break-all {change.type == 'add' ? 'bg-success/10'
? 'bg-success/10' : change.type == 'del'
: change.type == 'del' ? 'bg-error/10'
? 'bg-error/10' : ''}"
: ''}" >
> <!-- eslint-disable-next-line svelte/no-at-html-tags -->
<!-- eslint-disable-next-line svelte/no-at-html-tags --> {@html hljs.highlight(
{@html hljs.highlight( change.type == 'normal'
change.type == 'normal' ? change.content
? change.content : change.content.substring(1),
: change.content.substring(1), {
{ language:
language: (file.to || file.from)?.split('.').pop() || '', (file.to || file.from)?.split('.').pop() || '',
} }
).value} ).value}
</div>
</div> </div>
</div> {/each}
{/each} </div>
{/each} {/each}
</div> </div>
{/if} {/if}

Loading…
Cancel
Save