Skip to content

Commit 93d6548

Browse files
committed
Fix bug with partial committing
1 parent 6c220bc commit 93d6548

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

Frontend/src/scripts/features/repo/filter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function bindFilter() {
88
filterInput?.addEventListener('input', () => renderList());
99
selectAllBox?.addEventListener('change', () => {
1010
if (prefs.tab !== 'changes') return;
11-
state.defaultSelectAll = false;
11+
disableDefaultSelectAll();
1212
const files = getVisibleFiles();
1313
toggleSelectAll(Boolean(selectAllBox?.checked), files);
1414
renderList();

Frontend/src/scripts/features/repo/hydrate.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ export async function hydrateStatus() {
2727
state.files = Array.isArray(result?.files) ? (result.files as any) : [];
2828
const currentPaths = new Set((state.files || []).map((f) => f.path));
2929
if (state.defaultSelectAll) {
30+
state.selectionImplicitAll = true;
3031
state.selectedFiles = new Set(Array.from(currentPaths));
3132
} else {
33+
state.selectionImplicitAll = false;
3234
state.selectedFiles.forEach((p) => { if (!currentPaths.has(p)) state.selectedFiles.delete(p); });
3335
}
3436
(state as any).ahead = Number((result as any)?.ahead || 0);
@@ -39,6 +41,7 @@ export async function hydrateStatus() {
3941
console.warn('hydrateStatus failed', e);
4042
state.files = [];
4143
state.selectedFiles.clear();
44+
state.selectionImplicitAll = false;
4245
renderList();
4346
window.dispatchEvent(new CustomEvent('app:status-updated'));
4447
}

Frontend/src/scripts/features/repo/interactions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { buildCtxMenu, CtxItem } from '../../lib/menu';
22
import { notify } from '../../lib/notify';
33
import { TAURI } from '../../lib/tauri';
4-
import { state } from '../../state/state';
4+
import { state, disableDefaultSelectAll } from '../../state/state';
55
import type { FileStatus } from '../../types';
66
import { openStashConfirm } from '../stashConfirm';
77
import { dragState, listEl } from './context';
@@ -33,7 +33,7 @@ export function onFileClick(e: MouseEvent, file: FileStatus, index: number, visi
3333
if (state.selectedFiles.has(p)) state.selectedFiles.delete(p);
3434
else state.selectedFiles.add(p);
3535
}
36-
state.defaultSelectAll = false;
36+
disableDefaultSelectAll();
3737
updateSelectAllState(visible);
3838
renderListAfterRangeSelect(file);
3939
} else if (isToggle) {
@@ -124,7 +124,7 @@ export function onFileMouseDown(e: MouseEvent, file: FileStatus, index: number,
124124
}
125125

126126
export function applySelect(path: string, on: boolean, rowEl: HTMLElement | null, visible: FileStatus[], mode: 'diff' | 'commit') {
127-
state.defaultSelectAll = false;
127+
disableDefaultSelectAll();
128128
if (mode === 'commit') {
129129
if (on) state.selectedFiles.add(path); else state.selectedFiles.delete(path);
130130
if (rowEl) rowEl.classList.toggle('picked', on);

Frontend/src/scripts/state/state.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const state = {
2424
behind: 0 as number, // commits behind upstream
2525
aheadIds: new Set<string>() as Set<string>, // IDs of commits ahead of upstream
2626
defaultSelectAll: true as boolean, // by default select all files/hunks until user toggles
27+
selectionImplicitAll: true as boolean, // true when select-all was auto-applied (no manual picks yet)
2728
// Selection state
2829
selectedFiles: new Set<string>(),
2930
currentFile: '' as string,
@@ -53,3 +54,15 @@ export const statusClass = (s: string) =>
5354
s === 'A' ? 'add' :
5455
s === 'M' ? 'mod' :
5556
s === 'D' ? 'del' : 'mod';
57+
58+
// Disable the implicit "select all" mode. When clearImplicit is true, drop the
59+
// auto-filled selection set so later logic only sees explicit user picks.
60+
export function disableDefaultSelectAll(clearImplicit = false): boolean {
61+
const hadImplicit = state.defaultSelectAll && state.selectionImplicitAll;
62+
if (clearImplicit && hadImplicit) {
63+
state.selectedFiles.clear();
64+
}
65+
state.defaultSelectAll = false;
66+
state.selectionImplicitAll = false;
67+
return Boolean(clearImplicit && hadImplicit);
68+
}

0 commit comments

Comments
 (0)