diff --git a/e2e/gitLogScrollbar.spec.ts b/e2e/gitLogScrollbar.spec.ts index fa7daeb35..f162c1c1e 100644 --- a/e2e/gitLogScrollbar.spec.ts +++ b/e2e/gitLogScrollbar.spec.ts @@ -76,6 +76,47 @@ test.beforeEach(async ({ workbench: page }) => { }); }); +test("fits a wide graph and saved columns without horizontal scrolling", async ({ workbench: page }) => { + await page.evaluate(async () => { + const module = "/src/features/vcs/logOptions.ts"; + const { useLogOptions } = await import(/* @vite-ignore */ module); + useLogOptions.setState({ + showColumnHeaders: true, + showHash: true, + showSignature: true, + columnWidths: { author: 400, date: 240 }, + }); + }); + const list = page.getByRole("listbox", { name: "Commits" }); + await expect(list.getByRole("separator", { name: "Resize Date column" })).toBeVisible(); + + for (const width of [1400, 620, 400]) { + await page.setViewportSize({ width, height: 900 }); + await expect + .poll(() => + list.evaluate((element) => { + const header = [...element.querySelectorAll("[data-log-column]")]; + const row = [...element.querySelector('[role="option"]')!.children]; + const right = element.getBoundingClientRect().right; + return { + fits: element.scrollWidth === element.clientWidth, + aligned: header.every((cell, i) => { + const heading = cell.getBoundingClientRect(); + const data = row[i]!.getBoundingClientRect(); + return heading.width > 0 && heading.right <= right && Math.abs(heading.right - data.right) < 1; + }), + }; + }), + ) + .toEqual({ fits: true, aligned: true }); + } + + await list.hover(); + await page.mouse.wheel(450, 450); + await expect.poll(() => list.evaluate((element) => element.scrollTop)).toBeGreaterThan(0); + expect(await list.evaluate((element) => element.scrollLeft)).toBe(0); +}); + test("keeps a wide Git graph filled during scrollbar drags and its edges interactive afterwards", async ({ workbench: page, }) => { diff --git a/src/features/vcs/GitLog.module.css b/src/features/vcs/GitLog.module.css index 7dba08e7e..aac911289 100644 --- a/src/features/vcs/GitLog.module.css +++ b/src/features/vcs/GitLog.module.css @@ -168,7 +168,7 @@ .list { flex: 1; min-height: 0; - overflow: auto; + overflow: hidden auto; outline: none; /* Rows coming and going while scrolling relay out the list alone, not the workbench. */ contain: strict; @@ -181,8 +181,8 @@ height: 26px; display: flex; align-items: center; - gap: var(--space-2); - padding: 0 8px; + gap: min(var(--space-2), 2%); + padding: 0 min(var(--space-2), 2%); white-space: nowrap; cursor: default; font-size: var(--fs-ui); @@ -199,18 +199,18 @@ background: var(--bg-app); } .columnCell { - flex: none; + flex: 0 1 auto; + min-width: 0; overflow: hidden; text-overflow: ellipsis; /* Keep the first glyph clear of the divider on this column's left edge. box-sizing: border-box keeps the width and boundary position unchanged. */ - padding-inline-start: var(--space-2); + padding-inline-start: min(var(--space-2), 2%); /* Anchor for the full-height column resize strip (IDEA's invisible divider). */ position: relative; } .columnHeading { position: relative; - padding-inline-end: 6px; cursor: grab; touch-action: none; } @@ -314,7 +314,7 @@ --log-row-bg: var(--bg-tree-selected); } .colSubject { - flex: 1; + flex: 1 0 min(220px, 50%); min-width: 0; display: flex; align-items: center; @@ -365,9 +365,12 @@ } .graph { flex: none; + /* Leave room for the subject when the graph has many lanes: the lanes past it are cut off, not squeezed. */ + max-width: calc(100% - min(120px, 50%)); fill: none; stroke-width: 1.6; overflow: visible; + clip-path: inset(-50% 0); } .refs { flex: 0 1 auto; @@ -760,7 +763,8 @@ } .colRepository { - flex: 0 0 100px; + flex: 0 1 100px; + min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; diff --git a/src/features/vcs/log/ColumnHeaders.tsx b/src/features/vcs/log/ColumnHeaders.tsx index db5154529..a2ae7c5e2 100644 --- a/src/features/vcs/log/ColumnHeaders.tsx +++ b/src/features/vcs/log/ColumnHeaders.tsx @@ -26,15 +26,7 @@ const HIDDEN_COLUMN_OPTION: Record = { repository: "showRepository", }; -export function ColumnHeaders({ - columns, - options, - minWidth, -}: { - columns: LogColumn[]; - options: LogOptions; - minWidth: number; -}) { +export function ColumnHeaders({ columns, options }: { columns: LogColumn[]; options: LogOptions }) { const [drag, setDrag] = useState(null); const ids = columnSequence(options.columnOrder, columns); const cancel = useCallback(() => setDrag(null), []); @@ -47,10 +39,7 @@ export function ColumnHeaders({ }; const visibleIds = ids.filter((id) => id === SUBJECT_COLUMN.id || columns.some((column) => column.id === id)); return ( -
+
{options.showRepository && useVcs.getState().roots.length > 1 && ( {tx("Repository")} )} diff --git a/src/features/vcs/log/CommitList.tsx b/src/features/vcs/log/CommitList.tsx index cfb883450..939503e4c 100644 --- a/src/features/vcs/log/CommitList.tsx +++ b/src/features/vcs/log/CommitList.tsx @@ -43,7 +43,7 @@ import { currentRepo, currentRepoRoot, useVcs } from "../store"; import { ColumnHeaders } from "./ColumnHeaders"; import { CommitSignature } from "./CommitMessage"; import { CommitRow } from "./CommitRow"; -import { LANE, ROW, type LogColumn, type RowEvents } from "./shared"; +import { ROW, type LogColumn, type RowEvents } from "./shared"; const remoteNameSets = new WeakMap>(); @@ -197,15 +197,6 @@ export function CommitList() { ), }; }, [hoverColor, linear, displayedGraph, headKeys]); - const minWidth = useMemo( - () => - rows.reduce((width, row) => Math.max(width, row.width * LANE), 100) + - columns.reduce( - (width, column) => width + (opts.columnWidths[column.id] ?? column.width ?? 120), - opts.showRepository && useVcs.getState().roots.length > 1 ? 220 : 120, - ), - [rows, columns, opts.columnWidths, opts.showRepository], - ); const filterBranches = useGitLog((s) => s.filters.branches); const currentBranch = useVcs((s) => s.branch?.head ?? null); // Nothing to tell apart when the log is filtered to the current branch. @@ -581,11 +572,11 @@ export function CommitList() { ); }} > - {opts.showColumnHeaders && } + {opts.showColumnHeaders && } {!commits.length && !loading && finished && (
{headCommit ? tx("No commits match the filters") : tx("No commits yet")}
)} -
+
{items.map((v) => { const c = commits[v.index]; if (!c) diff --git a/src/features/vcs/log/GraphCell.tsx b/src/features/vcs/log/GraphCell.tsx index fe2f19ac0..a5150baad 100644 --- a/src/features/vcs/log/GraphCell.tsx +++ b/src/features/vcs/log/GraphCell.tsx @@ -39,6 +39,7 @@ export function GraphCell({ interactive?: boolean; }) { const cy = ROW / 2; + const width = row.width * LANE; const draw = (s: GraphSegment, i: number, up: boolean) => { const fromX = x(s.fromX ?? s.from); const toX = x(s.toX ?? s.to); @@ -112,7 +113,7 @@ export function GraphCell({ return ( onHover?.(null)}