Skip to content

Commit cafe2ba

Browse files
committed
Remove useage of group in the idSelection retain
The selection ID does not make use of the notion of groups, so we can add a special case to the id type for the selectionKey function
1 parent 8132105 commit cafe2ba

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

apps/desktop/src/components/v3/WorktreeChanges.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@
6666
if (affectedPaths) {
6767
untrack(() => {
6868
changeSelection.retain(affectedPaths);
69-
// TODO: We need to make this consider all groups
70-
idSelection.retain(affectedPaths, { type: 'ungrouped' });
69+
// TODO: Consider whether this is the best place for this to
70+
// live.
71+
idSelection.retain(affectedPaths);
7172
});
7273
}
7374
});

apps/desktop/src/lib/selection/idSelection.svelte.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
type SelectedFile
88
} from '$lib/selection/key';
99
import { SvelteSet } from 'svelte/reactivity';
10-
import type { HunkGroup } from '$lib/hunks/diffService.svelte';
1110
import type { StackService } from '$lib/stacks/stackService.svelte';
1211
import type { WorktreeService } from '$lib/worktree/worktreeService.svelte';
1312

@@ -136,13 +135,13 @@ export class IdSelection {
136135
* current worktree changes. Note that this function is a special case
137136
* for a particular key. It feels a bit out of place.
138137
*/
139-
retain(paths: string[] | undefined, group: HunkGroup) {
138+
retain(paths: string[] | undefined) {
140139
if (paths === undefined) {
141140
this.selections.clear();
142141
return;
143142
}
144143
const removedFiles: SelectedFile[] = [];
145-
const worktreeSelection = this.selections.get(selectionKey({ type: 'worktree', group }));
144+
const worktreeSelection = this.selections.get(selectionKey({ type: 'worktree' }));
146145
if (!worktreeSelection) return;
147146

148147
for (const selectedFile of worktreeSelection.entries) {

apps/desktop/src/lib/selection/key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function readKey(key: SelectedFileKey): SelectedFile {
7777
}
7878
}
7979

80-
export function selectionKey(id: SelectionId): SelectedFileKey {
80+
export function selectionKey(id: SelectionId | { type: 'worktree' }): SelectedFileKey {
8181
switch (id.type) {
8282
case 'commit':
8383
return `${id.type}:${id.commitId}` as SelectedFileKey;

0 commit comments

Comments
 (0)