From 20f253c3c5b3194ee305c0c5d38c667ebdbcb79f Mon Sep 17 00:00:00 2001 From: Caleb Owens Date: Thu, 30 May 2024 18:06:34 +0200 Subject: [PATCH] Fix shift clicking files --- app/src/lib/components/BranchFilesList.svelte | 6 ++---- app/src/lib/utils/selectFilesInList.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/lib/components/BranchFilesList.svelte b/app/src/lib/components/BranchFilesList.svelte index f7f346151..fedb45117 100644 --- a/app/src/lib/components/BranchFilesList.svelte +++ b/app/src/lib/components/BranchFilesList.svelte @@ -21,8 +21,6 @@ const fileIdSelection = getContext(FileIdSelection); const commit = getCommitStore(); - let sortedFiles: AnyFile[] = []; - function chunk(arr: T[], size: number) { return Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => arr.slice(i * size, i * size + size) @@ -78,11 +76,11 @@ showCheckbox={showCheckboxes} selected={$fileIdSelection.includes(stringifyFileKey(file.id, $commit?.id))} on:click={(e) => { - selectFilesInList(e, file, fileIdSelection, sortedFiles, allowMultiple, $commit); + selectFilesInList(e, file, fileIdSelection, displayedFiles, allowMultiple, $commit); }} on:keydown={(e) => { e.preventDefault(); - maybeMoveSelection(e.key, file, sortedFiles, fileIdSelection); + maybeMoveSelection(e.key, file, displayedFiles, fileIdSelection); }} /> {/each} diff --git a/app/src/lib/utils/selectFilesInList.ts b/app/src/lib/utils/selectFilesInList.ts index 99ff9cc7b..b64cf22f5 100644 --- a/app/src/lib/utils/selectFilesInList.ts +++ b/app/src/lib/utils/selectFilesInList.ts @@ -22,7 +22,7 @@ export function selectFilesInList( } } else if (e.shiftKey && allowMultiple) { const initiallySelectedIndex = sortedFiles.findIndex( - (file) => stringifyFileKey(file.id, undefined) == selectedFileIds[0] + (f) => f.id == fileIdSelection.only()?.fileId ); // detect the direction of the selection