|
8 | 8 | import { tick } from "svelte"; |
9 | 9 |
|
10 | 10 | interface Props { |
11 | | - index: number; |
12 | 11 | value: FileDetails; |
13 | 12 | } |
14 | 13 |
|
15 | 14 | const viewer = MultiFileDiffViewerState.get(); |
16 | 15 | const globalOptions = GlobalOptions.get(); |
17 | | - let { index, value }: Props = $props(); |
| 16 | + let { value }: Props = $props(); |
18 | 17 |
|
19 | 18 | let popoverOpen = $state(false); |
20 | 19 |
|
21 | 20 | async function showInFileTree() { |
22 | 21 | viewer.layoutState.sidebarCollapsed = false; |
23 | 22 | await tick(); |
24 | 23 |
|
25 | | - const fileTreeElement = document.getElementById("file-tree-file-" + index); |
| 24 | + const fileTreeElement = document.getElementById("file-tree-file-" + value.index); |
26 | 25 | if (fileTreeElement) { |
27 | 26 | popoverOpen = false; |
28 | 27 | viewer.tree?.expandParents((node) => node.type === "file" && node.file === value); |
|
46 | 45 | }); |
47 | 46 |
|
48 | 47 | function selectHeader() { |
49 | | - viewer.scrollToFile(index, { autoExpand: false, smooth: true }); |
| 48 | + viewer.scrollToFile(value.index, { autoExpand: false, smooth: true }); |
50 | 49 | viewer.setSelection(value, undefined); |
51 | 50 | } |
52 | 51 |
|
|
70 | 69 |
|
71 | 70 | {#snippet collapseToggle()} |
72 | 71 | <button |
73 | | - title={viewer.fileStates[index].collapsed ? "Expand file" : "Collapse file"} |
| 72 | + title={viewer.fileStates[value.index].collapsed ? "Expand file" : "Collapse file"} |
74 | 73 | type="button" |
75 | 74 | class="flex size-6 items-center justify-center rounded-sm btn-ghost p-0.5" |
76 | 75 | onclick={(e) => { |
77 | | - viewer.toggleCollapse(index); |
| 76 | + viewer.toggleCollapse(value.index); |
78 | 77 | e.stopPropagation(); |
79 | 78 | }} |
80 | 79 | > |
81 | | - {#if viewer.fileStates[index].collapsed} |
| 80 | + {#if viewer.fileStates[value.index].collapsed} |
82 | 81 | <span aria-label="expand file" class="iconify size-4 shrink-0 text-em-med octicon--chevron-right-16" aria-hidden="true"></span> |
83 | 82 | {:else} |
84 | 83 | <span aria-label="collapse file" class="iconify size-4 shrink-0 text-em-med octicon--chevron-down-16" aria-hidden="true"></span> |
|
101 | 100 | <LabeledCheckbox |
102 | 101 | labelText="File viewed" |
103 | 102 | bind:checked={ |
104 | | - () => viewer.fileStates[index].checked, |
| 103 | + () => viewer.fileStates[value.index].checked, |
105 | 104 | () => { |
106 | | - viewer.toggleChecked(index); |
| 105 | + viewer.toggleChecked(value.index); |
107 | 106 | popoverOpen = false; |
108 | 107 | } |
109 | 108 | } |
|
121 | 120 | {/snippet} |
122 | 121 |
|
123 | 122 | <div |
124 | | - id="file-header-{index}" |
| 123 | + id="file-header-{value.index}" |
125 | 124 | class={[ |
126 | 125 | "sticky top-0 z-10 flex flex-row items-center gap-2 border-b bg-neutral px-2 py-1 text-sm shadow-sm", |
127 | 126 | "focus-and-selected-styles focus:outline-none", |
|
133 | 132 | data-selected={boolAttr(selected)} |
134 | 133 | > |
135 | 134 | {#if value.type === "text"} |
136 | | - <DiffStats brief add={viewer.stats.fileAddedLines[index]} remove={viewer.stats.fileRemovedLines[index]} /> |
| 135 | + <DiffStats brief add={viewer.stats.fileAddedLines[value.index]} remove={viewer.stats.fileRemovedLines[value.index]} /> |
137 | 136 | {/if} |
138 | 137 | {@render fileName()} |
139 | 138 | <div class="ms-0.5 ml-auto flex items-center gap-1"> |
|
0 commit comments