Skip to content

Commit

Permalink
feat: add option to hide large numbers of diffs to improve UI perform…
Browse files Browse the repository at this point in the history
…ance
  • Loading branch information
krlvi committed Feb 24, 2024
1 parent 2a10996 commit ceb81c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gitbutler-ui/src/lib/components/FileDiff.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import Button from './Button.svelte';
import HunkViewer from './HunkViewer.svelte';
import Icon from './Icon.svelte';
import { computeAddedRemovedByHunk } from '$lib/utils/metrics';
Expand Down Expand Up @@ -30,13 +31,22 @@
$: maxLineNumber = sections[sections.length - 1]?.maxLineNumber;
$: minWidth = getGutterMinWidth(maxLineNumber);
let alwaysShow = false;
</script>

<div class="hunks">
{#if isBinary}
Binary content not shown
{:else if isLarge}
Diff too large to be shown
{:else if sections.length > 50 && !alwaysShow}
<div class="flex flex-col p-1">
Change hidden as large numbers of diffs may slow down the UI
<Button kind="outlined" color="neutral" on:click={() => (alwaysShow = true)}
>show anyways</Button
>
</div>
{:else}
{#each sections as section}
{@const { added, removed } = computeAddedRemovedByHunk(section)}
Expand Down

0 comments on commit ceb81c6

Please sign in to comment.