дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 17:21:13 +02:00
fix(vcs): mark the active changelist bold and list it first (#8004)
The Commit tool window meant to draw only the active changelist in bold, but the stylesheet only gave inactive lists font-weight 400, the weight every group label already has, so the active list looked like the others. Lists also appeared in creation order. The active list is now bold and comes first, the other lists follow by name in natural order, and Unversioned Files stays last. Refs #7433 Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
1 джерело
56c6e8090a
коміт
4eab243ef2
4 files changed
+87
-4
No files matched your search
@@ -330,8 +330,8 @@
|
||||
background: color-mix(in srgb, var(--accent) 12%, transparent);
|
||||
}
|
||||
/* Only the active change list is bold, as in IDEA. */
|
||||
.inactiveList {
|
||||
font-weight: 400;
|
||||
.activeList {
|
||||
font-weight: 600;
|
||||
}
|
||||
.messageError {
|
||||
box-shadow: inset 0 0 0 1px var(--danger);
|
||||
|
||||
@@ -1304,7 +1304,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
|
||||
styles.label,
|
||||
n.type === "group" && styles.groupLabel,
|
||||
staging && n.type === "group" && styles.stageGroupLabel,
|
||||
n.type === "group" && n.changelist && !n.active && styles.inactiveList,
|
||||
n.type === "group" && n.changelist && n.active && styles.activeList,
|
||||
)}
|
||||
style={n.type === "file" && n.kind ? { color: KIND_COLOR[n.kind] } : undefined}
|
||||
{...(n.type === "file" && n.kind && tooltipAttrs(KIND_LABEL[n.kind]))}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Issue #7433: the active changelist stands out in the Commit tool window as in IDEA
|
||||
* (ChangesBrowserChangeListNode): its name is bold and it comes first, the other lists
|
||||
* follow by name, and Unversioned Files stays after them.
|
||||
*/
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
return { ...real, call: vi.fn(async () => null) };
|
||||
});
|
||||
|
||||
vi.mock("../DiffEditor", () => ({ DiffEditor: () => <div /> }));
|
||||
|
||||
import type { ChangelistState } from "@/bindings";
|
||||
import { buildChangeTree } from "../changes";
|
||||
import { ChangesTree } from "../CommitView";
|
||||
import { useChangelists } from "../changelists";
|
||||
import { useCommit } from "../commitStore";
|
||||
import { useVcs } from "../store";
|
||||
|
||||
const change = (path: string, unstaged: "modified" | "untracked" = "modified") => ({
|
||||
path,
|
||||
relPath: path.replace(/^\/p\//, ""),
|
||||
staged: null,
|
||||
unstaged,
|
||||
renamedFrom: null,
|
||||
});
|
||||
|
||||
const status = [change("/p/a.ts"), change("/p/b.ts"), change("/p/c.ts"), change("/p/new.txt", "untracked")];
|
||||
|
||||
// The active list was created last; the default list keeps its id but is not active.
|
||||
const lists: ChangelistState = {
|
||||
lists: [
|
||||
{ id: "default", name: "Default Changelist", comment: "" },
|
||||
{ id: "skip", name: "不提交", comment: "" },
|
||||
{ id: "list10", name: "Task 10", comment: "" },
|
||||
{ id: "list9", name: "task 9", comment: "" },
|
||||
{ id: "work", name: "更改", comment: "" },
|
||||
],
|
||||
active: "work",
|
||||
files: { "a.ts": "default", "b.ts": "skip", "c.ts": "work" },
|
||||
};
|
||||
|
||||
const groupLabels = (nodes: ReturnType<typeof buildChangeTree>) => nodes.map((n) => n.label);
|
||||
|
||||
describe("the active changelist", () => {
|
||||
it("comes first, the other lists follow by name, Unversioned Files last", () => {
|
||||
expect(groupLabels(buildChangeTree(status, "/p", false, lists))).toEqual([
|
||||
"更改",
|
||||
"Default Changelist",
|
||||
"task 9",
|
||||
"Task 10",
|
||||
"不提交",
|
||||
"Unversioned Files",
|
||||
]);
|
||||
});
|
||||
|
||||
describe("in the Commit tool window", () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear();
|
||||
useCommit.setState({ groupByDir: false, checks: new Map(), selection: [] });
|
||||
useChangelists.setState({ state: lists });
|
||||
useVcs.setState({ root: "/p", repo: "/p", roots: ["/p"], heads: {}, status });
|
||||
});
|
||||
|
||||
it("is the only list drawn bold", () => {
|
||||
render(<ChangesTree mode="commit" />);
|
||||
const bold = (name: string) => screen.getByText(name, { exact: true }).className.includes("activeList");
|
||||
expect(bold("更改")).toBe(true);
|
||||
for (const name of ["Default Changelist", "不提交", "task 9", "Task 10", "Unversioned Files"]) {
|
||||
expect(bold(name), name).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -420,7 +420,13 @@ export function buildChangeTree(
|
||||
const id = groupOf(f) === "unversioned" ? lists.active : lists.files?.[relTo(root, stripSlash(f.path))];
|
||||
byList.get(id && byList.has(id) ? id : lists.active)?.push(f);
|
||||
}
|
||||
for (const l of lists.lists) {
|
||||
// The active list first, the others by name, as IDEA sorts them (ChangesBrowserChangeListNode).
|
||||
const ordered = [...lists.lists].sort(
|
||||
(a, b) =>
|
||||
Number(b.id === lists.active) - Number(a.id === lists.active) ||
|
||||
a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: "base" }),
|
||||
);
|
||||
for (const l of ordered) {
|
||||
const own = byList.get(l.id) ?? [];
|
||||
// Empty lists are shown once the user has more than the default one.
|
||||
if (!own.length && lists.lists.length < 2) continue;
|
||||
|
||||
Reference in new issue
Заблокувати користувача