diff --git a/e2e/commit.spec.ts b/e2e/commit.spec.ts index 8a54125031..12600e7dbf 100644 --- a/e2e/commit.spec.ts +++ b/e2e/commit.spec.ts @@ -98,3 +98,59 @@ test("commit message history opens above the message without an empty icon colum expect(Math.abs(menuBox!.x - messageBox!.x)).toBeLessThan(2); await expect(row.locator("span")).toHaveCount(1); }); + +test("the Commit changes toolbar fits a narrow side pane", async ({ workbench: page }) => { + await stubRepository(page); + await page.keyboard.press("Meta+k"); + await page.evaluate(async () => { + const path = "/src/workbench/toolwindows/store.ts"; + const layout = await import(/* @vite-ignore */ path); + layout.moveToolWindow("commit", "left"); + layout.setToolWindowSize("left", 164); + }); + const panel = page.getByRole("region", { name: "Commit", exact: true }); + const toolbar = panel.getByRole("toolbar", { name: "Changes" }); + await expect(toolbar).toBeVisible(); + const clipped = await toolbar.evaluate((bar) => { + const bounds = bar.getBoundingClientRect(); + return [...bar.querySelectorAll("button")].flatMap((button) => { + const box = button.getBoundingClientRect(); + return box.right > bounds.right + 1 || box.bottom > bounds.bottom + 1 ? [button.ariaLabel] : []; + }); + }); + expect(clipped).toEqual([]); + const push = panel.getByRole("button", { name: "Commit and Push…" }); + const overflow = await push.locator("span").evaluate((label) => label.scrollWidth - label.clientWidth); + expect(overflow).toBeLessThanOrEqual(1); + await toolbar.getByRole("button", { name: "Collapse All" }).click(); + await expect(panel.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden(); +}); + +test("the commit message uses the configured editor typography", async ({ workbench: page }) => { + await stubRepository(page); + await page.keyboard.press("Meta+k"); + const message = page.getByRole("textbox", { name: "Commit message" }); + await expect(message).toBeFocused(); + await page.evaluate(async () => { + const path = "/src/platform/project.ts"; + const { useProject } = await import(/* @vite-ignore */ path); + const settings = useProject.getState().settings; + useProject.setState({ + settings: { + ...settings, + editor: { + ...settings?.editor, + fontFamily: "Fira Code", + fallbackFont: "Maple Mono NF CN", + fontSize: 17, + lineHeight: 28, + fontWeight: 500, + }, + }, + }); + }); + await expect(message).toHaveCSS("font-size", "17px"); + await expect(message).toHaveCSS("line-height", "28px"); + await expect(message).toHaveCSS("font-weight", "500"); + await expect(message).toHaveCSS("font-family", /"Fira Code".*"Maple Mono NF CN"/); +}); diff --git a/src/features/vcs/CommitView.module.css b/src/features/vcs/CommitView.module.css index c1f917a9f3..ba4840a9e8 100644 --- a/src/features/vcs/CommitView.module.css +++ b/src/features/vcs/CommitView.module.css @@ -26,6 +26,20 @@ gap: var(--space-0-5); padding: 0 6px; } +.changesToolbar { + height: auto; + min-height: 32px; + flex-wrap: wrap; + column-gap: var(--space-2); + padding-block: var(--space-0-5); +} +.changesTools { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-0-5); + max-width: 100%; +} .sep { width: 1px; height: 16px; @@ -106,13 +120,12 @@ } .commitBar { flex: none; - height: 32px; + min-height: 32px; display: flex; + flex-wrap: wrap; align-items: center; - gap: var(--space-1); - padding: 0 6px 0 12px; - white-space: nowrap; - overflow: hidden; + gap: var(--space-0-5) var(--space-1); + padding: var(--space-0-5) 6px var(--space-0-5) 12px; } .grow { flex: 1; @@ -121,6 +134,7 @@ color: var(--fg-faint); font-family: var(--font-mono); font-size: var(--fs-tiny); + white-space: nowrap; } .lineLenWarn { color: var(--warning); @@ -136,8 +150,6 @@ border-top: 1px solid var(--border); outline: none; color: var(--fg-strong); - font-family: var(--font-mono); - font-size: var(--fs-code); line-height: var(--lh-code); -webkit-user-select: text; user-select: text; @@ -164,7 +176,6 @@ display: flex; align-items: center; gap: var(--space-2); - /* A narrow panel moves Commit and Push… to its own row rather than cutting its label. */ flex-wrap: wrap; padding: 8px 6px 10px 10px; white-space: nowrap; @@ -175,10 +186,14 @@ .commitActions > .pushButton { flex: 0 1 auto; min-width: 0; + min-height: var(--h-button, 28px); + height: auto; + padding: var(--space-1) var(--space-3); + line-height: 1.3; } .pushButton > span { - overflow: hidden; - text-overflow: ellipsis; + white-space: normal; + overflow-wrap: anywhere; } .stashList { flex: 1; diff --git a/src/features/vcs/CommitView.tsx b/src/features/vcs/CommitView.tsx index 325e1543c4..c8c6f989aa 100644 --- a/src/features/vcs/CommitView.tsx +++ b/src/features/vcs/CommitView.tsx @@ -18,7 +18,9 @@ import { import { tx, txTemplate } from "@/platform/i18n"; import clsx from "clsx"; import { executeAction } from "@/platform/actions"; -import { basename, dirname } from "@/platform/project"; +import { fontWeightOf } from "@/platform/editorSettings"; +import { resolveMonoFont } from "@/platform/fonts"; +import { basename, dirname, useProject } from "@/platform/project"; import { isTestFile, useEffectiveRoots } from "@/platform/projectRoots"; import { Button, @@ -763,68 +765,79 @@ export function ChangesTree({ mode }: { mode: "commit" | "local" | "dialog" }) { return (
-
- void refreshNow()} /> - {mode === "local" && } - - {mode === "local" && } - {mode !== "dialog" && } - - viewRef.current && - showContextMenu(bottomLeft(viewRef.current), [ - { kind: "header", label: "Group By" }, - { label: "Directory", checked: groupByDir, run: () => setGroupByDir(!groupByDir) }, - // IDEA offers it once the project has several repositories. - ...(repos.length > 1 - ? [{ label: "Repository", checked: groupByRepo, run: () => setGroupByRepo(!groupByRepo) }] - : []), - ...(staging - ? [] - : [{ label: "Staging State", checked: groupByStaging, run: () => setGroupByStaging(!groupByStaging) }]), - { kind: "separator" }, - { - label: "Show Unversioned Files Separately", - checked: showUnversionedSeparately, - run: () => setShowUnversionedSeparately(!showUnversionedSeparately), - }, - ...(mode === "local" - ? [ - { kind: "separator" } as const, - { label: "Show Diff Preview", checked: diffPreview, run: () => setDiffPreview(!diffPreview) }, - ] - : []), - // Not in the Commit dialog, whose files always open as source. - ...(mode === "dialog" ? [] : doubleClickMenu(doubleClickOpensDiff)), - ]) - } - /> - {/* WebStorm's Preview Diff: an embedded diff of the selection beside the changes (#1599). */} - {mode === "commit" && ( +
+
+ void refreshNow()} /> + {mode === "local" && } + + {mode === "local" && } + {mode !== "dialog" && } setCommitDiffPreview(!commitDiffPreview)} + aria-haspopup="menu" + onClick={() => + viewRef.current && + showContextMenu(bottomLeft(viewRef.current), [ + { kind: "header", label: "Group By" }, + { label: "Directory", checked: groupByDir, run: () => setGroupByDir(!groupByDir) }, + // IDEA offers it once the project has several repositories. + ...(repos.length > 1 + ? [{ label: "Repository", checked: groupByRepo, run: () => setGroupByRepo(!groupByRepo) }] + : []), + ...(staging + ? [] + : [ + { + label: "Staging State", + checked: groupByStaging, + run: () => setGroupByStaging(!groupByStaging), + }, + ]), + { kind: "separator" }, + { + label: "Show Unversioned Files Separately", + checked: showUnversionedSeparately, + run: () => setShowUnversionedSeparately(!showUnversionedSeparately), + }, + ...(mode === "local" + ? [ + { kind: "separator" } as const, + { label: "Show Diff Preview", checked: diffPreview, run: () => setDiffPreview(!diffPreview) }, + ] + : []), + // Not in the Commit dialog, whose files always open as source. + ...(mode === "dialog" ? [] : doubleClickMenu(doubleClickOpensDiff)), + ]) + } /> - )} - - {mode !== "dialog" && ( - - )} - setCollapsed(new Set())} /> - setCollapsed(new Set([...byKey.values()].filter((n) => n.type !== "file").map((n) => n.key)))} - /> + {/* WebStorm's Preview Diff: an embedded diff of the selection beside the changes (#1599). */} + {mode === "commit" && ( + setCommitDiffPreview(!commitDiffPreview)} + /> + )} +
+
+ {mode !== "dialog" && ( + + )} + setCollapsed(new Set())} /> + + setCollapsed(new Set([...byKey.values()].filter((n) => n.type !== "file").map((n) => n.key))) + } + /> +
{mode !== "dialog" && }
s.vcs.commit); + const editor = useProject((s) => s.settings?.editor); + const { family, size } = resolveMonoFont(undefined, editor); const first = message.split("\n")[0] ?? ""; const tooLong = cfg.limitSubject && first.length > cfg.subjectLimit; const problems = messageProblems(message, cfg).filter((p) => !p.startsWith("Subject line")); @@ -1182,7 +1197,13 @@ export function CommitMessageField({ data-autofocus={autoFocus ? "" : undefined} className={clsx(styles.message, !showMargin && styles.noMargin, emptyError && styles.messageError)} aria-invalid={emptyError || undefined} - style={{ ["--guide" as string]: `${margin}ch` }} + style={{ + ["--guide" as string]: `${margin}ch`, + fontFamily: family, + fontSize: size, + fontWeight: fontWeightOf(editor?.fontWeight, 400), + lineHeight: editor?.lineHeight ? `${editor.lineHeight}px` : undefined, + }} value={message} placeholder={tx("Commit Message")} aria-label={tx("Commit message")}