feat(status-panel): enhance file staging and un-staging functionality
This update improves the file staging and un-staging process by allowing multiple files to be selected and acted upon simultaneously. The user interface has been enhanced to provide clear feedback on the number of selected files and their respective statuses. - Added support for staging and un-staging multiple files at once - Introduced visual indicators for selected files in the UI - Improved event handling for file selection and actions
This commit is contained in:
+16
-8
@@ -2521,22 +2521,30 @@
|
||||
|
||||
// ── File staging / restore ─────────────────────────────────────────────────
|
||||
|
||||
async function stageFile(file: GitFileStatus) {
|
||||
await runOperation(`Staging ${file.path}`, async () => {
|
||||
applyStatus(await stageFiles(activeRepoPath, [file.path]));
|
||||
async function stageFile(files: GitFileStatus[]) {
|
||||
const targets = files.filter((file) => file.unstaged !== null);
|
||||
if (targets.length === 0) return;
|
||||
const paths = targets.map((file) => file.path);
|
||||
await runOperation(targets.length === 1 ? `Staging ${targets[0].path}` : `Staging ${targets.length} files`, async () => {
|
||||
applyStatus(await stageFiles(activeRepoPath, paths));
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
trackEvent("file_staged", {
|
||||
status: file.unstaged ?? file.staged ?? "unknown",
|
||||
files: targets.length,
|
||||
status: targets.length === 1 ? (targets[0].unstaged ?? targets[0].staged ?? "unknown") : "multiple",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function unstageFile(file: GitFileStatus) {
|
||||
await runOperation(`Unstaging ${file.path}`, async () => {
|
||||
applyStatus(await unstageFiles(activeRepoPath, [file.path]));
|
||||
async function unstageFile(files: GitFileStatus[]) {
|
||||
const targets = files.filter((file) => file.staged !== null);
|
||||
if (targets.length === 0) return;
|
||||
const paths = targets.map((file) => file.path);
|
||||
await runOperation(targets.length === 1 ? `Unstaging ${targets[0].path}` : `Unstaging ${targets.length} files`, async () => {
|
||||
applyStatus(await unstageFiles(activeRepoPath, paths));
|
||||
await refreshExplorerFiles(activeRepoPath);
|
||||
trackEvent("file_unstaged", {
|
||||
status: file.staged ?? file.unstaged ?? "unknown",
|
||||
files: targets.length,
|
||||
status: targets.length === 1 ? (targets[0].staged ?? targets[0].unstaged ?? "unknown") : "multiple",
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user