Fix shift clicking files

This commit is contained in:
Caleb Owens 2024-05-30 18:06:34 +02:00
parent a4878b234d
commit 20f253c3c5
2 changed files with 3 additions and 5 deletions

View File

@ -21,8 +21,6 @@
const fileIdSelection = getContext(FileIdSelection);
const commit = getCommitStore();
let sortedFiles: AnyFile[] = [];
function chunk<T>(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}

View File

@ -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