From 4f697bf274dc6fbd8d7f2a4df40e0865bb17c162 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 2 Dec 2026 19:07:39 +0800 Subject: [PATCH] fix(settings): align field edges across settings sections --- e2e/gradleSettingsLayout.spec.ts | 12 ++ e2e/settingsFormLayout.spec.ts | 41 ++++++ e2e/settingsPaneLayout.spec.ts | 23 ++++ .../settings/components/Form.module.css | 10 +- .../settings/languages/LanguagePages.tsx | 122 +++++++++-------- .../languages/ProjectStructurePage.tsx | 27 ++-- .../settings/languages/Sdk.module.css | 68 ++++++---- .../settings/pages/GitSettings.module.css | 34 +++++ .../settings/pages/editor/Editor.module.css | 5 + .../settings/pages/editor/codeStyle.tsx | 1 + src/features/settings/pages/editor/kit.tsx | 24 ++-- src/features/settings/pages/vcs.tsx | 123 +++++++++--------- 12 files changed, 319 insertions(+), 171 deletions(-) diff --git a/e2e/gradleSettingsLayout.spec.ts b/e2e/gradleSettingsLayout.spec.ts index e8e66e05b..091bcc317 100644 --- a/e2e/gradleSettingsLayout.spec.ts +++ b/e2e/gradleSettingsLayout.spec.ts @@ -44,6 +44,18 @@ test("Gradle keeps the local installation with Distribution and saves edits in p await expect(distribution).toHaveText("Gradle wrapper"); await expect(installation).toHaveCount(0); + const fields = userHome.or(runUsing).or(distribution).or(jvm); + for (const width of [1120, 800, 520]) { + await page.setViewportSize({ width, height: 760 }); + const edges = await fields.evaluateAll((elements) => + elements.map((element) => { + const { left, right } = element.getBoundingClientRect(); + return [Math.round(left), Math.round(right)]; + }), + ); + expect(edges).toHaveLength(4); + for (const edge of edges.slice(1)) expect(edge).toEqual(edges[0]); + } await distribution.click(); await page.getByRole("option", { name: "Local installation", exact: true }).click(); const browse = installation.locator("..").getByRole("button", { name: /^Browse/ }); diff --git a/e2e/settingsFormLayout.spec.ts b/e2e/settingsFormLayout.spec.ts index 7a0c5c455..a413cd533 100644 --- a/e2e/settingsFormLayout.spec.ts +++ b/e2e/settingsFormLayout.spec.ts @@ -74,6 +74,47 @@ test("settings forms share control columns and keep font metrics on one row", as } }); +test("toolchain, encoding and Subversion settings align field frames across sections", async ({ workbench: page }) => { + await page.keyboard.press("Meta+,"); + const body = page.getByRole("dialog", { name: "Settings", exact: true }).locator("[class*='pageBody']"); + for (const [id, title, count] of [ + ["languages.go", "Go", 2], + ["languages.java", "Java", 4], + ["languages.rust", "Rust", 4], + ["languages.node", "JavaScript Runtime", 4], + ["languages.php", "PHP", 4], + ["build.maven", "Maven", 8], + ["editor.fileEncodings", "File Encodings", 4], + ["vcs.svn", "Subversion", 2], + ] as const) { + await selectPage(page, id); + await expect(page.getByLabel("Breadcrumb").locator('[aria-current="page"]')).toHaveText(title); + if (id === "vcs.svn") { + await body.getByRole("checkbox", { name: "Use custom configuration directory" }).check(); + await expect(body.getByRole("textbox", { name: /Configuration directory/ })).toBeEnabled(); + } + const fields = body + .getByRole("button") + .and(body.locator("[aria-haspopup='listbox']")) + .or(body.getByRole("textbox")) + .or(body.getByRole("combobox")) + .and(body.locator(':not([aria-label="Thread count"])')); + await expect(fields).toHaveCount(count); + for (const width of [1200, 800, 520]) { + await page.setViewportSize({ width, height: 800 }); + for (const group of [fields, body.getByRole("button", { name: "Browse…", exact: true })]) { + const edges = await group.evaluateAll((elements) => + elements.map((element) => { + const { left, right } = element.getBoundingClientRect(); + return [Math.round(left), Math.round(right)]; + }), + ); + for (const edge of edges.slice(1)) expect(edge, `${id} at ${width}px`).toEqual(edges[0]); + } + } + } +}); + for (const locale of ["en", "zh"]) { test(`${locale} forms fit narrow settings panes without horizontal scrolling`, async ({ workbench: page }) => { await page.keyboard.press("Meta+,"); diff --git a/e2e/settingsPaneLayout.spec.ts b/e2e/settingsPaneLayout.spec.ts index a3e265afa..d8445a227 100644 --- a/e2e/settingsPaneLayout.spec.ts +++ b/e2e/settingsPaneLayout.spec.ts @@ -117,6 +117,29 @@ test("Live Templates gives the editor the full settings pane width and keeps var expect(await variables.evaluate((element) => element.scrollWidth - element.clientWidth)).toBe(0); }); +test("Project settings aligns the visible fields and their browse buttons", async ({ workbench: page }) => { + await page.keyboard.press("Meta+;"); + const dialog = page.getByRole("dialog", { name: "Project Structure", exact: true }); + const fields = dialog + .getByRole("button", { name: /^(Project SDK|Project language level|Language server JDK)$/ }) + .or(dialog.getByRole("textbox", { name: "Compiler output" })); + const browse = dialog.getByRole("button", { name: "Browse…" }); + await expect(fields).toHaveCount(4); + await expect(browse).toHaveCount(3); + for (const width of [1400, 800, 520]) { + await page.setViewportSize({ width, height: 800 }); + for (const group of [fields, browse]) { + const edges = await group.evaluateAll((elements) => + elements.map((element) => { + const { left, right } = element.getBoundingClientRect(); + return [Math.round(left), Math.round(right)]; + }), + ); + for (const edge of edges.slice(1)) expect(edge).toEqual(edges[0]); + } + } +}); + test("Project Structure keeps every details pane usable in a compact window", async ({ workbench: page }) => { await page.keyboard.press("Meta+;"); const dialog = page.getByRole("dialog", { name: "Project Structure", exact: true }); diff --git a/src/features/settings/components/Form.module.css b/src/features/settings/components/Form.module.css index e8a1023ff..722bbef1a 100644 --- a/src/features/settings/components/Form.module.css +++ b/src/features/settings/components/Form.module.css @@ -38,9 +38,17 @@ min-width: 0; } .formGroup > .row, -.formGroup > .formGroup { +.formGroup > .formGroup, +.formGroup > .section, +.formGroup > .section > .sectionBody { grid-template-columns: subgrid; } +.formGroup > .section { + display: grid; +} +.formGroup > .section > * { + grid-column: 1 / -1; +} .formGroup > .stacked, .formGroup > .toggleRow { grid-template-columns: minmax(0, 1fr); diff --git a/src/features/settings/languages/LanguagePages.tsx b/src/features/settings/languages/LanguagePages.tsx index 5d8665101..61921ff40 100644 --- a/src/features/settings/languages/LanguagePages.tsx +++ b/src/features/settings/languages/LanguagePages.tsx @@ -10,7 +10,7 @@ import { useCallback, useEffect, useId, useMemo, useState } from "react"; import { call, commands, type FlutterVersion, type Sdk } from "@/platform/ipc"; import { IconButton, Input, type SelectOption, T } from "@/ui"; import { JAVA_LANGUAGE_LEVELS, PHP_LANGUAGE_LEVELS } from "@/platform/languageSettings"; -import { GlobListEditor, Row, Section, Select, Toggle } from "../components/Form"; +import { FormGroup, GlobListEditor, Row, Section, Select, Toggle, type RowProps } from "../components/Form"; import { choosePath } from "@/platform/choosePath"; import { usePageContext, useSetting } from "../components/context"; import { SdkField, tildify, useDetected, useJdtlsJdk } from "./components"; @@ -19,6 +19,14 @@ import { mavenHomeProblem } from "./mavenHome"; import { PathField, PathInput } from "./PathInput"; import styles from "./Sdk.module.css"; +function FieldRow({ children, ...row }: RowProps) { + return ( + + {children} + + ); +} + function SdkRow({ k, label, @@ -47,9 +55,9 @@ function RunTargetRow({ language }: { language: "php" | "node" }) { if (target && target !== "local" && !targets.some((t) => t.id === target)) options.push({ value: target, label: tx`Run in target ${target}` }); return ( - + - - + + - + -
+
-
+
{selected.version}} {xdebug !== undefined && {xdebug ?? Not installed}}
- + ); } @@ -263,8 +271,8 @@ export function RustPage() { const selected = list.find((s) => s.path === toolchain); const argsId = useId(); return ( -
-
+ +
-
- +
+
-
+ ); } @@ -544,8 +552,8 @@ export function MavenPage() { const [activeProfiles, setActiveProfiles] = useSetting("languages.java.maven.activeProfiles"); const id = useId(); return ( -
-
+ +
-
+
- @@ -645,7 +653,7 @@ export function MavenPage() { { value: "maven", label: "Maven" }, ]} /> - + - setActiveProfiles(e.target.value)} aria-label="Active profiles" /> - +
-
+
-
+ ); } diff --git a/src/features/settings/languages/ProjectStructurePage.tsx b/src/features/settings/languages/ProjectStructurePage.tsx index 4c058e0eb..6d7936dd7 100644 --- a/src/features/settings/languages/ProjectStructurePage.tsx +++ b/src/features/settings/languages/ProjectStructurePage.tsx @@ -68,7 +68,7 @@ import { type ProjectStructureValid, } from "@/platform/languageSettings"; import { initProjectRoots, useDetectedRoots } from "@/platform/projectRoots"; -import { Row, SearchLabel, Section } from "../components/Form"; +import { FormGroup, Row, SearchLabel, Section } from "../components/Form"; import { detectSdks, forgetSdk, rememberSdk, useSdks, type SdkKind } from "./api"; import { choosePath } from "@/platform/choosePath"; import { DownloadJdkDialog } from "./DownloadJdkDialog"; @@ -340,8 +340,8 @@ function ProjectSection() { const outId = useId(); return ( -
-
+ +
{name || "Default Project"} @@ -364,19 +364,21 @@ function ProjectSection() { label="Language level" hint="Default Java language level for source code assistance and compilation across project modules." > - + - + setCompilerOutput(e.target.value)} />
-
+
-
+ ); } diff --git a/src/features/settings/languages/Sdk.module.css b/src/features/settings/languages/Sdk.module.css index a09f92b99..410e3d33f 100644 --- a/src/features/settings/languages/Sdk.module.css +++ b/src/features/settings/languages/Sdk.module.css @@ -17,6 +17,38 @@ flex: 1; min-width: 0; } +.projectSettings { + container: settings-content / inline-size; + row-gap: var(--space-2); + overflow-wrap: anywhere; +} +.toolchainSettings { + overflow-wrap: anywhere; +} +.projectSettings .sdkField, +.toolchainSettings .sdkField, +.toolchainSettings .pathRow, +.localDistribution, +.alignedField { + display: grid; + /* Reserve the refresh and browse columns even on rows with fewer actions. */ + grid-template-columns: minmax(0, 1fr) repeat(2, 20px); + align-items: center; + gap: var(--space-1); + width: 100%; + max-width: 560px; + min-width: 0; +} +.alignedField > :first-child, +.localDistribution > :first-child { + max-width: none; + width: 100%; + min-width: 0; +} +.alignedBrowse, +.toolchainSettings .pathRow > button { + grid-column: 3; +} /* Editable ComboBox (Maven home): a text field with the combo's arrow inside its frame. */ .sdkEditable { display: inline-flex; @@ -59,10 +91,8 @@ font-size: var(--fs-small); } -.mavenSettings .sdkField, -.mavenSettings .sdkEditable { +.toolchainSettings .sdkEditable { min-width: 0; - max-width: none; } .mavenThreads { @@ -328,28 +358,20 @@ min-width: 0; } -.gradleSettings .pathRow { - max-width: 560px; +.localDistribution { + grid-template-columns: minmax(0, 180px) minmax(0, 1fr) repeat(2, 20px); } - -.gradleSettings .sdkField { - min-width: 0; +.localDistribution > .pathRow { + grid-column: 2 / -1; + grid-template-columns: subgrid; } - -.gradleDistribution { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--space-2); - width: 560px; -} - -.gradleDistribution > :first-child { - flex: 0 1 180px; -} - -.gradleDistribution > .pathRow { - flex: 1 1 230px; +@container settings-content (max-width: 600px) { + .localDistribution { + grid-template-columns: minmax(0, 1fr) repeat(2, 20px); + } + .localDistribution > .pathRow { + grid-column: 1 / -1; + } } /* Project Structure */ diff --git a/src/features/settings/pages/GitSettings.module.css b/src/features/settings/pages/GitSettings.module.css index 60abe2b96..a89923126 100644 --- a/src/features/settings/pages/GitSettings.module.css +++ b/src/features/settings/pages/GitSettings.module.css @@ -52,3 +52,37 @@ grid-column: 1; } } + +/* Share the input, browse and Test columns across both Subversion paths. */ +section > :has(> .svnPath) { + grid-template-columns: fit-content(45%) minmax(0, 1fr) 20px max-content; +} + +.svnPath > div { + grid-column: 2 / -1; +} + +.svnPath > div:first-of-type { + display: grid; + grid-template-columns: subgrid; +} + +.svnPath input { + width: 100%; + min-width: 0; +} + +.svnConfig > label { + padding-inline-start: var(--space-4); +} + +@container settings-content (max-width: 440px) { + section > :has(> .svnPath) { + grid-template-columns: minmax(0, 1fr) 20px max-content; + } + + .svnPath > label, + .svnPath > div { + grid-column: 1 / -1; + } +} diff --git a/src/features/settings/pages/editor/Editor.module.css b/src/features/settings/pages/editor/Editor.module.css index f119ce682..6311292ab 100644 --- a/src/features/settings/pages/editor/Editor.module.css +++ b/src/features/settings/pages/editor/Editor.module.css @@ -4,6 +4,11 @@ max-width: 760px; } +.alignedFields button[aria-haspopup="listbox"] { + width: min(320px, 100%); + min-width: 0; +} + .check { display: flex; align-items: center; diff --git a/src/features/settings/pages/editor/codeStyle.tsx b/src/features/settings/pages/editor/codeStyle.tsx index 00c6010aa..996ce34d3 100644 --- a/src/features/settings/pages/editor/codeStyle.tsx +++ b/src/features/settings/pages/editor/codeStyle.tsx @@ -630,6 +630,7 @@ const ENCODINGS: SelectOption[] = ENCODING_CHOICES.map(([value, label]) => ({ va const ENCODINGS_PAGE = editorPage({ id: "editor.fileEncodings", + alignFields: true, title: "File Encodings", order: 27, projectScope: true, diff --git a/src/features/settings/pages/editor/kit.tsx b/src/features/settings/pages/editor/kit.tsx index 8a0ed9eff..3f65586d4 100644 --- a/src/features/settings/pages/editor/kit.tsx +++ b/src/features/settings/pages/editor/kit.tsx @@ -10,7 +10,7 @@ import clsx from "clsx"; import { Checkbox, Input, T, type SelectOption } from "@/ui"; import { executeAction } from "@/platform/actions"; import { tx } from "@/platform/i18n"; -import { NumberInput, Row, SearchLabel, Section, Select } from "../../components/Form"; +import { FormGroup, NumberInput, Row, SearchLabel, Section, Select } from "../../components/Form"; import { useLabelMatch, usePageContext, useSetting } from "../../components/context"; import type { PageSpec } from "../spec"; import styles from "./Editor.module.css"; @@ -67,6 +67,7 @@ export interface EditorPageDef { keywords?: string[]; projectScope?: boolean; sections: EditorSection[]; + alignFields?: boolean; /** Rendered below the sections (previews, tables). */ footer?: ComponentType; } @@ -324,18 +325,15 @@ export function ItemView({ item }: { item: Item }) { } } -export function EditorSections({ sections }: { sections: EditorSection[] }) { - return ( - <> - {sections.map((s, i) => ( -
- {s.items.map((item, j) => ( - - ))} -
+export function EditorSections({ sections, alignFields }: Pick) { + const body = sections.map((s, i) => ( +
+ {s.items.map((item, j) => ( + ))} - - ); +
+ )); + return alignFields ? {body} : <>{body}; } /** Search texts of an item tree (labels, option labels, custom keywords). */ @@ -365,7 +363,7 @@ export function editorPage(def: EditorPageDef): PageSpec { const Footer = def.footer; const Page = () => (
- + {Footer &&
}
); diff --git a/src/features/settings/pages/vcs.tsx b/src/features/settings/pages/vcs.tsx index 71cbf9107..4c8e245ab 100644 --- a/src/features/settings/pages/vcs.tsx +++ b/src/features/settings/pages/vcs.tsx @@ -385,47 +385,44 @@ function SvnExecutableRow() { } }; return ( -
- - {result.text} - - ) : undefined - } - > -
- { - setPath(e.target.value); - setResult(null); - }} - /> - { - const chosen = await choosePath({ directory: false, defaultPath: path || detected || undefined }); - if (chosen) { - setPath(chosen); - setResult(null); - } - }} - /> - -
-
-
+ + {result.text} + + ) : undefined + } + > + { + setPath(e.target.value); + setResult(null); + }} + /> + { + const chosen = await choosePath({ directory: false, defaultPath: path || detected || undefined }); + if (chosen) { + setPath(chosen); + setResult(null); + } + }} + /> + + ); } @@ -436,30 +433,26 @@ function SvnConfigDirRow() { return ( <> - - -
- setDir(e.target.value)} - /> - { - const chosen = await choosePath({ directory: true, defaultPath: dir || undefined }); - if (chosen) setDir(chosen); - }} - /> -
-
-
+ + setDir(e.target.value)} + /> + { + const chosen = await choosePath({ directory: true, defaultPath: dir || undefined }); + if (chosen) setDir(chosen); + }} + /> + ); }