Skip to content

Commit a79394c

Browse files
committed
Add progress for dir comparison
1 parent 7e8094e commit a79394c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

web/src/lib/diff-viewer-multi-file.svelte.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,10 @@ export class MultiFileDiffViewerState {
523523
// Pushing directly to the main array causes too many signals to update (lag)
524524
tempDetails.push(details);
525525

526-
const now = performance.now();
527-
if (now - lastYield > 50 || i % 100 === 0) {
526+
if (performance.now() - lastYield > 50 || i % 100 === 0) {
528527
await tick();
529528
await yieldToBrowser();
530-
lastYield = now;
529+
lastYield = performance.now();
531530
}
532531
}
533532
if (tempDetails.length === 0) {

web/src/routes/OpenDiffDialog.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@
181181
const entriesB: ProtoFileDetails[] = flatten(dirB).filter(blacklist);
182182
const entriesBMap = new Map(entriesB.map((entry) => [entry.path, entry]));
183183
184+
viewer.loadingState.totalCount = new Set([...entriesAMap.keys(), ...entriesBMap.keys()]).size;
185+
184186
for (const entry of entriesA) {
185187
const entryB = entriesBMap.get(entry.path);
186188
if (entryB) {
@@ -190,6 +192,7 @@
190192
if (aBinary || bBinary) {
191193
if (await bytesEqual(entry.file, entryB.file)) {
192194
// Files are identical
195+
viewer.loadingState.loadedCount++;
193196
continue;
194197
}
195198
if (isImageFile(entry.file.name) && isImageFile(entryB.file.name)) {
@@ -201,6 +204,7 @@
201204
const [textA, textB] = await Promise.all([entry.file.text(), entryB.file.text()]);
202205
if (textA === textB) {
203206
// Files are identical
207+
viewer.loadingState.loadedCount++;
204208
continue;
205209
}
206210
yield makeTextDetails(entry.path, entryB.path, "modified", createTwoFilesPatch(entry.path, entryB.path, textA, textB));

0 commit comments

Comments
 (0)