Skip to content

Commit fe1aedb

Browse files
committed
fix: strip files list after 500 entries in source control view
1 parent d989a71 commit fe1aedb

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<script lang="ts">
2+
export let files: unknown[];
3+
</script>
4+
5+
<!-- svelte-ignore a11y-click-events-have-key-events -->
6+
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
7+
<main>
8+
{#if files.length > 500}
9+
<div class="tree-item nav-file">
10+
<div
11+
class="tree-item-self nav-file-title"
12+
aria-label={"And " + (files.length - 500) + " more files"}
13+
>
14+
<div class="tree-item-inner nav-file-title-content">
15+
{"And " + (files.length - 500) + " more files"}
16+
</div>
17+
</div>
18+
</div>
19+
{/if}
20+
</main>

src/ui/sourceControl/components/treeComponent.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
import PulledFileComponent from "./pulledFileComponent.svelte";
1111
import StagedFileComponent from "./stagedFileComponent.svelte";
1212
import { mayTriggerFileMenu } from "src/utils";
13+
import TooManyFilesComponent from "./tooManyFilesComponent.svelte";
1314
export let hierarchy: StatusRootTreeItem;
1415
export let plugin: ObsidianGit;
1516
export let view: GitView;
1617
export let fileType: FileType;
1718
export let topLevel = false;
1819
const closed: Record<string, boolean> = {};
20+
21+
for (const entity of hierarchy.children) {
22+
closed[entity.title] = (entity.children?.length ?? 0) > 100;
23+
}
1924
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access */
2025
$: side = (view.leaf.getRoot() as any).side == "left" ? "right" : "left";
2126
@@ -60,7 +65,7 @@
6065
<!-- svelte-ignore a11y-click-events-have-key-events -->
6166
<!-- svelte-ignore a11y-no-static-element-interactions -->
6267
<main class:topLevel>
63-
{#each hierarchy.children as entity}
68+
{#each hierarchy.children.slice(0, 500) as entity}
6469
{#if entity.data}
6570
<div>
6671
{#if fileType == FileType.staged}
@@ -227,6 +232,8 @@
227232
</div>
228233
{/if}
229234
{/each}
235+
236+
<TooManyFilesComponent files={hierarchy.children} />
230237
</main>
231238

232239
<style lang="scss">

src/ui/sourceControl/sourceControl.svelte

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import StagedFileComponent from "./components/stagedFileComponent.svelte";
1818
import TreeComponent from "./components/treeComponent.svelte";
1919
import type GitView from "./sourceControl";
20+
import TooManyFilesComponent from "./components/tooManyFilesComponent.svelte";
2021
2122
export let plugin: ObsidianGit;
2223
export let view: GitView;
@@ -142,27 +143,18 @@
142143
};
143144
status.changed.sort(sort);
144145
status.staged.sort(sort);
145-
if (status.changed.length + status.staged.length > 500) {
146-
status = undefined;
147-
if (!plugin.loading) {
148-
plugin.displayError("Too many changes to display");
149-
}
150-
} else {
151-
changeHierarchy = {
152-
title: "",
153-
path: "",
154-
vaultPath: "",
155-
children: plugin.gitManager.getTreeStructure(
156-
status.changed
157-
),
158-
};
159-
stagedHierarchy = {
160-
title: "",
161-
path: "",
162-
vaultPath: "",
163-
children: plugin.gitManager.getTreeStructure(status.staged),
164-
};
165-
}
146+
changeHierarchy = {
147+
title: "",
148+
path: "",
149+
vaultPath: "",
150+
children: plugin.gitManager.getTreeStructure(status.changed),
151+
};
152+
stagedHierarchy = {
153+
title: "",
154+
path: "",
155+
vaultPath: "",
156+
children: plugin.gitManager.getTreeStructure(status.staged),
157+
};
166158
} else {
167159
changeHierarchy = undefined;
168160
stagedHierarchy = undefined;
@@ -404,13 +396,14 @@
404396
topLevel={true}
405397
/>
406398
{:else}
407-
{#each status.staged as stagedFile}
399+
{#each status.staged.slice(0, 500) as stagedFile}
408400
<StagedFileComponent
409401
change={stagedFile}
410402
{view}
411403
manager={plugin.gitManager}
412404
/>
413405
{/each}
406+
<TooManyFilesComponent files={status.staged} />
414407
{/if}
415408
</div>
416409
{/if}
@@ -520,13 +513,14 @@
520513
topLevel={true}
521514
/>
522515
{:else}
523-
{#each status.changed as change}
516+
{#each status.changed.slice(0, 500) as change}
524517
<FileComponent
525518
{change}
526519
{view}
527520
manager={plugin.gitManager}
528521
/>
529522
{/each}
523+
<TooManyFilesComponent files={status.changed} />
530524
{/if}
531525
</div>
532526
{/if}
@@ -586,6 +580,9 @@
586580
{#each lastPulledFiles as change}
587581
<PulledFileComponent {change} {view} />
588582
{/each}
583+
<TooManyFilesComponent
584+
files={lastPulledFiles}
585+
/>
589586
{/if}
590587
</div>
591588
{/if}

0 commit comments

Comments
 (0)