From 604e9348f2da71a228c9045034e106f28fc122e9 Mon Sep 17 00:00:00 2001 From: audichuang <72485427+audichuang@users.noreply.github.com> Date: Sat, 28 Nov 2026 07:01:37 +0800 Subject: [PATCH] fix(vcs): offer New Changelist and Move under Group By Staging State (#6596) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the staging area off and the Commit tool window grouped by Staging State, the Staged / Unstaged nodes carry no changelist, so Move to Another Changelist… was hidden and New Changelist… (only on changelist headers) was unreachable. Their nodes and files now offer Move to Another Changelist… in the first group and New Changelist… next to Create Patch and Shelve. Nothing changes with the staging area on. Fixes #6422 Co-authored-by: audichuang <72485427+audichuang@users.noreply.github.com> --- src/features/vcs/CommitView.tsx | 6 +++++- src/features/vcs/__tests__/stagingArea.test.tsx | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx index 1d4ac7938a..ee9a07250d 100644 --- a/src/features/vcs/CommitView.tsx +++ b/src/features/vcs/CommitView.tsx @@ -507,6 +507,8 @@ export function nodeMenu( ] : []), ]; + // Group By Staging State hides the lists, but its files still belong to one (#6422). + const inChangelist = !staging && nodes.some((n) => n.changelist || n.group === "staged" || n.group === "unstaged"); // The staging menu operates on the index. A change list can commit or move individual files. const primary: MenuItem[] = staging ? [...stageActions, stash, ...rollback, ...fileActions] @@ -518,7 +520,8 @@ export function nodeMenu( run: () => commitFiles(paths), }, ...rollback, - ...(nodes.some((n) => n.changelist) + // Group By Staging State hides the lists, but its files still belong to one, as in IDEA (#6422). + ...(inChangelist ? [ { kind: "action" as const, @@ -588,6 +591,7 @@ export function nodeMenu( { label: "Copy File Name", icon: "copy", run: () => copyChangePaths(nodes, "name") }, ...(staging ? [] : [{ kind: "separator" as const }, ...fileActions, ...stageActions]), { kind: "separator" }, + ...(inChangelist ? [{ kind: "action" as const, action: "vcs.changelist.new" }] : []), ...(canExportPatch ? [{ kind: "action" as const, action: "vcs.createPatch", arg: patchSelection }] : []), ...(canExportPatch ? [{ kind: "action" as const, action: "vcs.copyPatch", arg: patchSelection }] : []), { kind: "action", action: "vcs.shelve", arg: paths }, diff --git a/src/features/vcs/__tests__/stagingArea.test.tsx b/src/features/vcs/__tests__/stagingArea.test.tsx index d727678ad0..21dc162b0e 100644 --- a/src/features/vcs/__tests__/stagingArea.test.tsx +++ b/src/features/vcs/__tests__/stagingArea.test.tsx @@ -245,6 +245,21 @@ describe("staging operations of the tree's nodes", () => { expect(labels(nodeMenu([group("unstaged").children![0]!], []))).toContain("Commit File…"); }); + it("offers New Changelist and Move under Group By Staging State only while change lists are on (#6422)", () => { + const actions = (node: (typeof roots)[number]) => + nodeMenu([node], []).flatMap((item) => (item.kind === "action" ? [item.action] : [])); + useSettings(false); + for (const node of [group("staged"), group("unstaged"), group("unstaged").children![0]!]) { + expect(actions(node)).toContain("vcs.changelist.new"); + expect(actions(node)).toContain("vcs.changelist.move"); + } + useSettings(true); + for (const node of [group("staged"), group("unstaged").children![0]!]) { + expect(actions(node)).not.toContain("vcs.changelist.new"); + expect(actions(node)).not.toContain("vcs.changelist.move"); + } + }); + it.each([false, true])("groups the change menu for staging area = %s", (staging) => { useSettings(staging); const underUnstaged = group("unstaged").children!.find((n) => n.label === "Unstaged.kt")!; @@ -268,6 +283,7 @@ describe("staging operations of the tree's nodes", () => { "Copy File Name", ]); expect(groups).toContainEqual([ + ...(staging ? [] : ["vcs.changelist.new"]), "vcs.createPatch", "vcs.copyPatch", "vcs.shelve",