diff --git a/e2e/gitLogToolbarMenus.spec.ts b/e2e/gitLogToolbarMenus.spec.ts index f50c20a81..6be543777 100644 --- a/e2e/gitLogToolbarMenus.spec.ts +++ b/e2e/gitLogToolbarMenus.spec.ts @@ -60,6 +60,58 @@ test.beforeEach(async ({ workbench: page }) => { await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible(); }); +test("Git Log separates commit message typography from compact metadata", async ({ workbench: page }) => { + await page.setViewportSize({ width: 860, height: 720 }); + await page.evaluate(() => { + window.__ipc.handlers.vcs_log_details_batch = ({ revisions }) => + (revisions as string[]).map(() => ({ + message: "Commit 1\n\nUpdate checkout totals after applying shipping discounts.", + containingBranches: ["feature/update-checkout-totals-and-apply-shipping-discounts".repeat(3)], + signature: "N", + signer: "", + key: "", + fingerprint: "", + })); + }); + const setEditorSize = (fontSize: number) => + page.evaluate(async (fontSize) => { + const module = "/src/platform/project.ts"; + const { useProject } = await import(/* @vite-ignore */ module); + const { settings } = useProject.getState(); + useProject.setState({ + settings: { ...settings, editor: { ...settings?.editor, fontFamily: "Consolas", fontSize } }, + }); + }, fontSize); + await setEditorSize(18); + const commits = page.getByRole("listbox", { name: "Commits" }); + await commits.getByRole("option").filter({ hasText: "Commit 1" }).first().click(); + + const message = page.locator("#message"); + const subject = message.getByText("Commit 1", { exact: true }); + const body = message.getByText("Update checkout totals after applying shipping discounts.", { exact: true }); + await expect(body).toHaveCSS("font-size", "18px"); + await expect(body).toHaveCSS("font-family", /Consolas/); + await expect(subject).toHaveCSS("font-size", "18px"); + const author = message.getByTitle("Copy revision number").locator(".."); + const parent = message.getByText(/^Parent\s/); + await expect(author).toHaveCSS("font-size", "12px"); + const authorBox = (await author.boundingBox())!; + const parentBox = (await parent.boundingBox())!; + expect(parentBox.y - authorBox.y - authorBox.height).toBeLessThanOrEqual(4); + const signature = message.getByText(/Signature: Unsigned/); + await signature.scrollIntoViewIfNeeded(); + await expect(signature).toBeInViewport(); + const overflow = await message.evaluate((el) => { + const scroller = el.querySelector('[class*="_messageBox_"]')!; + return scroller.scrollWidth - scroller.clientWidth; + }); + expect(overflow).toBeLessThanOrEqual(1); + + await setEditorSize(15); + await expect(body).toHaveCSS("font-size", "15px"); + await expect(author).toHaveCSS("font-size", "12px"); +}); + test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => { const toolbar = page.getByRole("toolbar", { name: "Log filters" }); const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" }); diff --git a/src/features/vcs/GitLog.module.css b/src/features/vcs/GitLog.module.css index 40ca8526a..27a375a94 100644 --- a/src/features/vcs/GitLog.module.css +++ b/src/features/vcs/GitLog.module.css @@ -630,33 +630,36 @@ flex: 1; min-width: 0; } +.messageText { + white-space: pre-wrap; + overflow-wrap: anywhere; + line-height: 1.5; +} .subjectLine { color: var(--fg-strong); - font-weight: 600; - white-space: pre-wrap; - word-break: break-word; - line-height: 1.5; } .fullMessage { - margin-top: 6px; + margin-top: var(--space-1-5); color: var(--fg); - white-space: pre-wrap; - word-break: break-word; - line-height: 1.5; } .meta { - margin-top: 10px; + font-size: var(--fs-small); color: var(--fg-subtle); line-height: 1.5; + overflow-wrap: anywhere; +} +.messageText + .meta { + margin-top: var(--space-2); +} +.meta + .meta, +.commitEntry .messageText + .meta { + margin-top: var(--space-0-5); } .commitEntry + .commitEntry { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); } -.metaCompact { - margin-top: 2px; -} .meta .refs { margin-left: 0; max-width: none; @@ -670,6 +673,10 @@ .hash { font-family: var(--font-mono); } +.messageText .linkButton, +.meta .linkButton { + max-width: 100%; +} .linkButton { color: var(--link); font: inherit; diff --git a/src/features/vcs/log/CommitMessage.tsx b/src/features/vcs/log/CommitMessage.tsx index 02874db3f..f021f1a7f 100644 --- a/src/features/vcs/log/CommitMessage.tsx +++ b/src/features/vcs/log/CommitMessage.tsx @@ -1,6 +1,9 @@ import type { Commit } from "@/bindings"; import { writeClipboardText } from "@/platform/clipboard"; +import { fontWeightOf } from "@/platform/editorSettings"; +import { resolveMonoFont } from "@/platform/fonts"; import { tx } from "@/platform/i18n"; +import { useProject } from "@/platform/project"; import clsx from "clsx"; import styles from "../GitLog.module.css"; import { IssueText } from "../issueLinks"; @@ -47,24 +50,31 @@ export function RefLabels({ /** A commit's message and metadata; `compact` (one of several selected): without the body. */ export function CommitMessage({ commit, compact = false }: { commit: Commit; compact?: boolean }) { const { details, error } = useCommitDetails(commit, !compact); + const editor = useProject((s) => s.settings?.editor); + const { family, size } = resolveMonoFont(undefined, editor); const repo = commitRepo(commit) ?? currentRepo(); const message = details?.message || commit.message; const [subject, ...bodyLines] = message.replace(/\s+$/, "").split("\n"); const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, ""); return (
-
- -
- {body && ( -
- +
+
+
- )} -
+ {body && ( +
+ +
+ )} +
+
)} + {commit.refs.length > 0 && ( +
+ +
+ )} {details && ( <>
@@ -125,11 +140,6 @@ export function CommitMessage({ commit, compact = false }: { commit: Commit; com {tx("Could not load containing branches or signature details")}
)} - {commit.refs.length > 0 && ( -
- -
- )}
); }