From 81aa9418aa3841dac6d8aafcc09c1bf4c74cfbbe Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Wed, 18 Nov 2026 18:39:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(vcs):=20no=20Commit=20File=E2=80=A6=20in=20?= =?UTF-8?q?the=20changes=20tree=20with=20the=20staging=20area=20(#4246)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the staging area the commit takes the whole index, so Commit File… on a staged file only focused the message and committed every staged file. The item is left out of the changes tree's menu while the staging area is on, as the staging tree has no per-file commit. Fixes #4153 --- src/features/vcs/CommitView.tsx | 21 ++++++++++++------- .../vcs/__tests__/stagingArea.test.tsx | 9 ++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx index 0f54eb2d6..c88155ce1 100644 --- a/src/features/vcs/CommitView.tsx +++ b/src/features/vcs/CommitView.tsx @@ -67,7 +67,7 @@ import { import { applyStash, commitChanges, deleteFiles, dropStash, showUnstashDialog, stashChanges } from "./changeOps"; import { CommitOptionsPopup } from "./CommitOptions"; import { DEFAULT_LIST_NAME, useChangelists, withListDefaults } from "./changelists"; -import { inclusionChecks, isCommitAll, useStagingArea } from "./staging"; +import { inclusionChecks, isCommitAll, stagingAreaOn, useStagingArea } from "./staging"; import { addToChangelist, commitFiles } from "./changelistsUi"; import { acceptSide } from "./conflictsUi"; import { copyChangesAsPatch } from "./patches"; @@ -345,13 +345,18 @@ export function nodeMenu( { kind: "separator" as const }, ] : []), - { - label: "Commit File…", - icon: "commit", - disabled: !files.some((f) => groupOf(f) === "changes"), - run: () => commitFiles(paths), - }, - { kind: "separator" }, + // With the staging area a commit takes the whole index: there is no committing one file. + ...(stagingAreaOn() + ? [] + : [ + { + label: "Commit File…", + icon: "commit" as const, + disabled: !files.some((f) => groupOf(f) === "changes"), + run: () => commitFiles(paths), + }, + { kind: "separator" as const }, + ]), // Under the modal interface the node itself, like double-click, in the front window. vcsDiffInFront() && opts?.roots && first ? { diff --git a/src/features/vcs/__tests__/stagingArea.test.tsx b/src/features/vcs/__tests__/stagingArea.test.tsx index df87bf93a..cf72b11df 100644 --- a/src/features/vcs/__tests__/stagingArea.test.tsx +++ b/src/features/vcs/__tests__/stagingArea.test.tsx @@ -129,6 +129,15 @@ describe("staging operations of the tree's nodes", () => { enabled(nodeMenu([underUnstaged], []), "Unstage"), ]).toEqual([true, false]); }); + + it("has no Commit File…: a commit takes the whole index", () => { + useSettings(true); + const labels = (items: MenuItem[]) => items.map((i) => ("label" in i ? i.label : null)); + for (const node of [group("staged").children![0]!, group("unstaged").children![0]!]) + expect(labels(nodeMenu([node], []))).not.toContain("Commit File…"); + useSettings(false); + expect(labels(nodeMenu([group("unstaged").children![0]!], []))).toContain("Commit File…"); + }); }); describe("the Commit tool window with the staging area", () => {