From 56d97887472cd64fa14a166dba303b75758ca7e0 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 26 Nov 2026 16:10:01 +0800 Subject: [PATCH] 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 --- src/features/vcs/CommitView.tsx | 1 + .../changesHorizontalScroll.test.tsx | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/features/vcs/__tests__/changesHorizontalScroll.test.tsx diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx index 0c3653d095..b8b959a3bb 100644 --- a/src/features/vcs/CommitView.tsx +++ b/src/features/vcs/CommitView.tsx @@ -1130,6 +1130,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia > handleRef={treeRef} + horizontalScroll roots={roots} getKey={(n) => n.key} getLabel={nodeText} diff --git a/src/features/vcs/__tests__/changesHorizontalScroll.test.tsx b/src/features/vcs/__tests__/changesHorizontalScroll.test.tsx new file mode 100644 index 0000000000..75bc6e199c --- /dev/null +++ b/src/features/vcs/__tests__/changesHorizontalScroll.test.tsx @@ -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(); + return { ...real, call: vi.fn() }; +}); + +vi.mock("../DiffEditor", () => ({ DiffEditor: () =>
})); + +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(); + 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/); + }); +});