diff --git a/src/lib/components/events/content/Patch.svelte b/src/lib/components/events/content/Patch.svelte index 4fbee37..6b2590b 100644 --- a/src/lib/components/events/content/Patch.svelte +++ b/src/lib/components/events/content/Patch.svelte @@ -25,6 +25,8 @@ expand_files = expand_files.map((_) => true) } + let expand_full_files = files.map((_) => false) + function extractTagContent(name: string): string | undefined { let tag = tags.find((tag) => tag[0] === name) return tag ? tag[1] : undefined @@ -62,90 +64,162 @@ {#each files as file, index} -
- +
- + + + {#if expand_files[index]} -
- {#each file.chunks as chunk, index} -
+
+
+ {#each file.chunks as chunk, index} {#if index !== 0} -
+
...
{/if} {#each chunk.changes as change, i} -
+
{isAddChange(change) && i !== 0 && isDeleteChange(chunk.changes[i - 1]) - ? '' + ? ' ' : extractChangeLine(change)}
-
- - {@html hljs.highlight( - change.type == 'normal' - ? change.content - : change.content.substring(1), - { - language: - (file.to || file.from)?.split('.').pop() || '', - } - ).value} -
{/each} -
- {/each} + {/each} +
+
+ {#each file.chunks as chunk, index} +
+ {#if index !== 0} +
+ {/if} + {#each chunk.changes as change, i} +
+
+ + {@html hljs.highlight( + change.type == 'normal' + ? change.content + : change.content.substring(1), + { + language: + (file.to || file.from)?.split('.').pop() || '', + } + ).value} + {#if (change.type == 'normal' ? change.content : change.content.substring(1)).length === 0} + + + {/if} +
+
+ {/each} +
+ {/each} +
{/if}
+ + {#if expand_full_files[index]} +
+ + {#each file.chunks as chunk, index} + {#if index !== 0} + + {/if} + {#each chunk.changes as _, i} +   + + {/each} + {/each} +
+ {/if} {/each}