fix(vcs): scroll the changes tree horizontally instead of clipping rows

Rows in the Commit and Local Changes trees were locked to the pane width and
ellipsized, so the end of a long file name and its directory path could only
be read by widening the tool window. The tree now keeps rows at their natural
width and scrolls horizontally, as the Project view does.

Fixes #6080
Цей коміт міститься в:
l0ng-ai committed 2026-11-26 16:10:01 +08:00
1 джерело ef1b159544
коміт 56d9788747
2 files changed
+49

No files matched your search

+1
Переглянути файл
@@ -1130,6 +1130,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
>
<Tree<ChangeNode>
handleRef={treeRef}
horizontalScroll
roots={roots}
getKey={(n) => n.key}
getLabel={nodeText}
+48
Переглянути файл
@@ -0,0 +1,48 @@
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() };
});
vi.mock("../DiffEditor", () => ({ DiffEditor: () => <div /> }));
import { ChangesTree } from "../CommitView";
import { useVcs } from "../store";
import { useProject } from "@/platform/project";
const NAME = "some_long_service_implementation_with_a_very_long_name.ts";
describe("changes tree width (#6080)", () => {
beforeEach(() => {
localStorage.clear();
useProject.setState({
project: { name: "p", root: "/p", trusted: true, isGit: true, settings: {} } as never,
settings: {} as never,
});
useVcs.setState({
root: "/p",
repo: "/p",
roots: ["/p"],
status: [
{
path: `/p/src/features/some_long_module_name/${NAME}`,
relPath: `src/features/some_long_module_name/${NAME}`,
staged: null,
unstaged: "modified" as const,
renamedFrom: null,
},
],
});
});
it.each(["commit", "local"] as const)("scrolls horizontally in %s mode instead of clipping rows", (mode) => {
render(<ChangesTree mode={mode} />);
const tree = screen.getByRole("tree", { name: "Changes" });
// The rows keep their natural width and the tree tracks the widest one for its scroll range.
expect(tree.querySelector("[data-content-width]")).not.toBeNull();
const row = screen.getByText(NAME).closest("[data-row]") as HTMLElement;
expect(row.className).toMatch(/wideRow/);
});
});