diff --git a/src/components/Diff.svelte b/src/components/Diff.svelte
index 2183bb88b..dd33742d8 100644
--- a/src/components/Diff.svelte
+++ b/src/components/Diff.svelte
@@ -326,6 +326,172 @@
}
+{#snippet lineDiff(line: Modification, lineIdx: number, hunkIdx: number)}
+ {@const thread = findLineThread(line)}
+
+
{
+ if (codeComments?.createComment && !thread) {
+ selectLine(e, file, "left", line, hunkIdx, lineIdx);
+ }
+ }}>
+ {lineNumber(line, "left")}
+
+
+
{
+ if (codeComments?.createComment && !thread) {
+ selectLine(e, file, "right", line, hunkIdx, lineIdx);
+ }
+ }}>
+ {lineNumber(line, "right")}
+
+
+
+ {#if line.type === "addition"}
+ +
+ {:else if line.type === "deletion"}
+ -
+ {/if}
+
+
+ {#if line.highlight && line.highlight.items.length > 0}
+
+ {@html line.highlight.items
+ .map(
+ paint =>
+ `${escape(paint.item)}`,
+ )
+ .join("")}
+
+ {:else if line.line !== ""}
+
{line.line}
+ {:else}
+
+ {/if}
+
+
+
+
+ {#if codeComments && thread && !threadExpandedStates[thread.root.id]}
+
+
+ {@render commentHeader(
+ thread.root.location?.path,
+ rangeAnchorsFromCodeLocation(thread.root.location),
+ )}
+ {#if codeComments.changeCommentStatus && roles.isDelegateOrAuthor( codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), thread.root.author.did, )}
+
+ {#if thread.root.resolved}
+
+
+
+ {:else}
+
+
+
+ {/if}
+
+ {/if}
+
+
{
+ await codeComments.createComment(body, embeds, thread.root.id);
+ }
+ : undefined}
+ editComment={codeComments.editComment}
+ canEditComment={partial(
+ roles.isDelegateOrAuthor,
+ codeComments.config.publicKey,
+ codeComments.repoDelegates.map(delegate => delegate.did),
+ )} />
+
+ {/if}
+
+ {#if codeComments && selection?.hunkIdx === hunkIdx && selection?.lineIdx === lineIdx}
+
+ {/if}
+{/snippet}
+
{#snippet commentHeader(filePath?: string, selectionRange?: SelectionRange)}
{#if filePath && selectionRange}
- {#each hunk.lines as line, lineIdx}
- {@const thread = findLineThread(line)}
-
-
{
- if (codeComments?.createComment && !thread) {
- selectLine(e, file, "left", line, hunkIdx, lineIdx);
- }
- }}>
- {lineNumber(line, "left")}
-
-
-
{
- if (codeComments?.createComment && !thread) {
- selectLine(e, file, "right", line, hunkIdx, lineIdx);
- }
- }}>
- {lineNumber(line, "right")}
-
-
-
- {#if line.type === "addition"}
- +
- {:else if line.type === "deletion"}
- -
- {/if}
-
-
- {#if line.highlight && line.highlight.items.length > 0}
-
- {@html line.highlight.items
- .map(
- paint =>
- `${escape(paint.item)}`,
- )
- .join("")}
-
- {:else if line.line !== ""}
-
{line.line}
- {:else}
-
- {/if}
-
-
-
-
- {#if codeComments && thread && !threadExpandedStates[thread.root.id]}
-
-
- {@render commentHeader(
- thread.root.location?.path,
- rangeAnchorsFromCodeLocation(thread.root.location),
- )}
- {#if codeComments.changeCommentStatus && roles.isDelegateOrAuthor( codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), thread.root.author.did, )}
-
- {#if thread.root.resolved}
-
-
-
- {:else}
-
-
-
- {/if}
-
- {/if}
-
-
{
- await codeComments.createComment(
- body,
- embeds,
- thread.root.id,
- );
- }
- : undefined}
- editComment={codeComments.editComment}
- canEditComment={partial(
- roles.isDelegateOrAuthor,
- codeComments.config.publicKey,
- codeComments.repoDelegates.map(delegate => delegate.did),
- )} />
-
- {/if}
-
- {#if codeComments && selection && selection.hunkIdx === hunkIdx && selection.lineIdx === lineIdx && selection.codeLocation}
-
- {/if}
+ {#each hunk.lines as modification, lineIdx}
+ {@render lineDiff(modification, lineIdx, hunkIdx)}
{/each}
{/each}