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",