Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

fix(settings): consistent form columns, font page metrics and sidebar width (#2388)

l0ng-ai7f88d3d723d8
diff --git a/e2e/sdkFieldLayout.spec.ts b/e2e/sdkFieldLayout.spec.ts
index 2a56a8551..ee95ca1d8 100644
--- a/e2e/sdkFieldLayout.spec.ts
+++ b/e2e/sdkFieldLayout.spec.ts
@@ -66,19 +66,22 @@ test("Python interpreter controls stay separate and visible in a narrow settings
await expect(interpreter).toBeVisible();
for (const width of [1000, 800, 520]) {
await page.setViewportSize({ width, height: 760 });
- const combo = await interpreter.boundingBox();
- const button = await add.boundingBox();
- const row = await add.evaluate((el) => {
- const r = el.parentElement!.getBoundingClientRect();
- return { left: r.left, right: r.right };
- });
- expect(combo!.width).toBeGreaterThan(20);
- expect(combo!.x).toBeGreaterThanOrEqual(row.left - 1);
- expect(combo!.x + combo!.width).toBeLessThanOrEqual(row.right + 1);
- expect(button!.x + button!.width).toBeLessThanOrEqual(row.right + 1);
- const overlap =
- Math.min(combo!.x + combo!.width, button!.x + button!.width) > Math.max(combo!.x, button!.x) &&
- Math.min(combo!.y + combo!.height, button!.y + button!.height) > Math.max(combo!.y, button!.y);
- expect(overlap).toBe(false);
+ await expect
+ .poll(() =>
+ add.evaluate((el) => {
+ const row = el.parentElement!;
+ const bounds = row.getBoundingClientRect();
+ const combo = row.querySelector('[aria-label="Python interpreter"]')!.getBoundingClientRect();
+ const button = el.getBoundingClientRect();
+ return {
+ comboFits: combo.width > 20 && combo.left >= bounds.left - 1 && combo.right <= bounds.right + 1,
+ buttonFits: button.left >= bounds.left - 1 && button.right <= bounds.right + 1,
+ overlaps:
+ Math.min(combo.right, button.right) > Math.max(combo.left, button.left) &&
+ Math.min(combo.bottom, button.bottom) > Math.max(combo.top, button.top),
+ };
+ }),
+ )
+ .toEqual({ comboFits: true, buttonFits: true, overlaps: false });
}
});
diff --git a/e2e/settingsFormLayout.spec.ts b/e2e/settingsFormLayout.spec.ts
new file mode 100644
index 000000000..cf7056671
--- /dev/null
+++ b/e2e/settingsFormLayout.spec.ts
@@ -0,0 +1,89 @@
+import type { Page } from "@playwright/test";
+import { expect, test } from "./fixtures";
+
+async function selectPage(page: Page, id: string) {
+ await page.evaluate(async (id) => {
+ const path = "/src/features/settings/model/staging.ts";
+ (await import(/* @vite-ignore */ path)).selectPage(id);
+ }, id);
+}
+
+test("settings forms share control columns and keep font metrics on one row", async ({ workbench: page }) => {
+ await page.keyboard.press("Meta+,");
+ const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
+ await expect(dialog).toBeVisible();
+ await selectPage(page, "appearance");
+ const controls = ["Theme", "Editor color scheme"].map((name) => dialog.getByRole("button", { name, exact: true }));
+ for (const control of controls) await expect(control).toBeVisible();
+ const boxes = await Promise.all(controls.map((control) => control.boundingBox()));
+ for (const box of boxes) expect(box!.x).toBeCloseTo(boxes[0]!.x, 0);
+
+ await selectPage(page, "editor.font");
+ const font = dialog.getByRole("combobox", { name: "Font", exact: true });
+ const size = dialog.getByRole("textbox", { name: "Size", exact: true });
+ const line = dialog.getByRole("textbox", { name: "Line height", exact: true });
+ await expect(line).toBeVisible();
+ const [fontBox, sizeBox, lineBox] = await Promise.all([font.boundingBox(), size.boundingBox(), line.boundingBox()]);
+ expect(fontBox!.x).toBeCloseTo(sizeBox!.x, 0);
+ expect(lineBox!.y).toBeCloseTo(sizeBox!.y, 0);
+ expect(lineBox!.x).toBeGreaterThan(sizeBox!.x + sizeBox!.width);
+ const weights = await Promise.all(
+ ["Main font weight", "Bold font weight"].map((name) =>
+ dialog.getByRole("button", { name, exact: true }).boundingBox(),
+ ),
+ );
+ const fallback = await dialog.getByRole("combobox", { name: "Fallback font", exact: true }).boundingBox();
+ for (const box of weights) expect(box!.x).toBeCloseTo(fallback!.x, 0);
+ for (const name of ["Main font weight", "Bold font weight", "Fallback font"]) {
+ const singleLine = await dialog.getByText(name, { exact: true }).evaluate((el) => {
+ const range = document.createRange();
+ range.selectNodeContents(el);
+ return range.getBoundingClientRect().height <= Number.parseFloat(getComputedStyle(el).lineHeight) + 1;
+ });
+ expect(singleLine, name).toBe(true);
+ }
+});
+
+for (const locale of ["en", "zh"]) {
+ test(`${locale} forms fit narrow settings panes without horizontal scrolling`, async ({ workbench: page }) => {
+ await page.keyboard.press("Meta+,");
+ await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
+ await page.evaluate(async (locale) => {
+ const path = "/src/platform/i18n.ts";
+ await (await import(/* @vite-ignore */ path)).setLocale(locale);
+ }, locale);
+ for (const id of ["appearance", "editor.font", "general", "general.httpProxy"]) {
+ await selectPage(page, id);
+ const body = page.locator("[class*='pageBody']");
+ for (const width of [1000, 784, 640, 520]) {
+ await page.setViewportSize({ width, height: 760 });
+ await expect
+ .poll(() => body.evaluate((el) => el.scrollWidth - el.clientWidth), { message: `${id} at ${width}px` })
+ .toBeLessThanOrEqual(1);
+ }
+ }
+ });
+}
+
+test("settings sidebar resizes with mouse and keyboard and remembers its width", async ({ workbench: page }) => {
+ await page.keyboard.press("Meta+,");
+ const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
+ const handle = dialog.getByRole("separator", { name: "Settings pages", exact: true });
+ await expect(handle).toBeVisible();
+ const sidebar = dialog.locator("#navigation");
+ const initial = (await sidebar.boundingBox())!.width;
+ const box = (await handle.boundingBox())!;
+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ await page.mouse.down();
+ await page.mouse.move(box.x + 60, box.y + box.height / 2);
+ await page.mouse.up();
+ await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeGreaterThan(initial + 40);
+ const resized = (await sidebar.boundingBox())!.width;
+ await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
+ await page.keyboard.press("Meta+,");
+ await expect(handle).toBeVisible();
+ await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeCloseTo(resized, 0);
+ await handle.focus();
+ await page.keyboard.press("ArrowLeft");
+ await expect.poll(async () => (await sidebar.boundingBox())!.width).toBeLessThan(resized);
+});
diff --git a/src-tauri/src/windows.rs b/src-tauri/src/windows.rs
index 4841077fd..9a86f0132 100644
--- a/src-tauri/src/windows.rs
+++ b/src-tauri/src/windows.rs
@@ -36,7 +36,7 @@ const MAIN: &str = "main";
const PREFIX: &str = "project-";
const CASCADE: f64 = 28.0;
const SETTINGS_SIZE: (f64, f64) = (980.0, 720.0);
-const SETTINGS_MIN_SIZE: (f64, f64) = (640.0, 420.0);
+const SETTINGS_MIN_SIZE: (f64, f64) = (900.0, 700.0);
const COMPARISON_SIZE: (f64, f64) = (1100.0, 720.0);
const COMPARISON_MIN_SIZE: (f64, f64) = (640.0, 360.0);
const DEPLOYMENT_SIZE: (f64, f64) = (1400.0, 900.0);
@@ -1604,10 +1604,12 @@ pub(super) fn place_over_parent(window: &WebviewWindow, parent: &WebviewWindow)
if (bounds.2, bounds.3) != (own.width, own.height) {
// Sizes are set on the client area, and even an undecorated window has a resize frame.
let (width, height) = ((bounds.2 - frame.0).max(1.0), (bounds.3 - frame.1).max(1.0));
- window.set_min_size(Some(tauri::LogicalSize::new(
- SETTINGS_MIN_SIZE.0.min(width),
- SETTINGS_MIN_SIZE.1.min(height),
- )))?;
+ let minimum = match auxiliary(window.label()) {
+ Some((AuxKind::Comparison, _)) => COMPARISON_MIN_SIZE,
+ Some((AuxKind::Deployment, _)) => DEPLOYMENT_MIN_SIZE,
+ _ => SETTINGS_MIN_SIZE,
+ };
+ window.set_min_size(Some(tauri::LogicalSize::new(minimum.0.min(width), minimum.1.min(height))))?;
window.set_size(tauri::LogicalSize::new(width, height))?;
}
if maximized {
diff --git a/src/features/settings/components/FontPicker.module.css b/src/features/settings/components/FontPicker.module.css
index 280ba608f..586ebbb82 100644
--- a/src/features/settings/components/FontPicker.module.css
+++ b/src/features/settings/components/FontPicker.module.css
@@ -2,12 +2,14 @@
display: inline-flex;
flex-direction: column;
gap: 4px;
- max-width: 420px;
- min-width: 200px;
+ width: 280px;
+ max-width: 100%;
+ min-width: 0;
}
.controls {
display: flex;
gap: 6px;
+ min-width: 0;
}
.controls input {
min-width: 0;
diff --git a/src/features/settings/components/FontPicker.tsx b/src/features/settings/components/FontPicker.tsx
index 9ebc4d75e..55812964d 100644
--- a/src/features/settings/components/FontPicker.tsx
+++ b/src/features/settings/components/FontPicker.tsx
@@ -1,5 +1,5 @@
import { useId, useRef, useState } from "react";
-import { Button, Input, Popup, T } from "@/ui";
+import { IconButton, Input, Popup, T } from "@/ui";
import { useTx } from "@/platform/i18n";
import { loadSystemFonts, useSystemFonts } from "@/platform/systemFonts";
import styles from "./FontPicker.module.css";
@@ -100,13 +100,12 @@ export function FontPicker({
}
}}
/>
- <Button
+ <IconButton
+ icon="refresh"
disabled={disabled || status === "loading"}
onClick={() => void loadSystemFonts(true)}
- aria-label={tx("Refresh system fonts")}
- >
- <T>Refresh</T>
- </Button>
+ title={tx("Refresh system fonts")}
+ />
</span>
<span id={`${listId}-status`} className={styles.hint} role="status">
{tx(message)}
diff --git a/src/features/settings/components/Form.module.css b/src/features/settings/components/Form.module.css
index 657222174..43884e714 100644
--- a/src/features/settings/components/Form.module.css
+++ b/src/features/settings/components/Form.module.css
@@ -22,15 +22,34 @@
background: var(--border);
}
.sectionBody {
- display: flex;
- flex-direction: column;
padding-left: 18px;
}
+.formGroup {
+ display: grid;
+ grid-template-columns: fit-content(45%) minmax(0, 1fr);
+ column-gap: var(--space-2);
+ min-width: 0;
+}
+.formGroup > * {
+ grid-column: 1 / -1;
+ min-width: 0;
+}
+.formGroup > .row,
+.formGroup > .formGroup {
+ grid-template-columns: subgrid;
+}
+.formGroup > .stacked,
+.formGroup > .toggleRow {
+ grid-template-columns: minmax(0, 1fr);
+}
+.indented {
+ padding-left: 20px;
+}
.row {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
- align-items: center;
+ align-items: start;
column-gap: 8px;
min-height: 28px;
padding: 2px 6px;
@@ -49,8 +68,12 @@
}
.label {
color: var(--fg);
+ padding-top: max(0px, calc((var(--h-field) - 1.4em) / 2));
white-space: nowrap;
}
+.stacked > .label {
+ padding-top: 0;
+}
.row:not(.stacked) > .label::after {
content: ":";
}
@@ -60,11 +83,16 @@
.control {
display: flex;
align-items: center;
+ flex-wrap: wrap;
gap: 8px;
min-width: 0;
+ min-height: var(--h-field);
+}
+.control > * {
+ max-width: 100%;
}
.hint {
- grid-column: 1 / -1;
+ grid-column: 2;
color: var(--fg-subtle);
font-size: var(--fs-small);
line-height: 1.4;
@@ -75,8 +103,12 @@
min-height: 26px;
}
.toggleHint {
+ grid-column: 1 / -1;
padding-left: 20px;
}
+.stacked > .hint {
+ grid-column: 1 / -1;
+}
.number {
display: inline-flex;
@@ -91,13 +123,19 @@
color: var(--fg-subtle);
}
.select {
- min-width: 180px;
- max-width: 320px;
+ min-width: min(180px, 100%);
+ max-width: min(320px, 100%);
}
.text {
width: 240px;
}
+@container settings-content (max-width: 480px) {
+ .label {
+ white-space: normal;
+ }
+}
+
.swatches {
display: flex;
align-items: center;
diff --git a/src/features/settings/components/Form.tsx b/src/features/settings/components/Form.tsx
index a5ea9a0ea..5ca89be93 100644
--- a/src/features/settings/components/Form.tsx
+++ b/src/features/settings/components/Form.tsx
@@ -50,11 +50,23 @@ export function Section({ title, children, className }: { title?: string; childr
<span className={styles.sectionRule} aria-hidden />
</div>
)}
- <div className={styles.sectionBody}>{children}</div>
+ <FormGroup className={styles.sectionBody}>{children}</FormGroup>
</section>
);
}
+export function FormGroup({
+ children,
+ indented,
+ className,
+}: {
+ children: ReactNode;
+ indented?: boolean;
+ className?: string;
+}) {
+ return <div className={clsx(styles.formGroup, indented && styles.indented, className)}>{children}</div>;
+}
+
export interface RowProps {
label: string;
hint?: ReactNode;
diff --git a/src/features/settings/dialog/SettingsDialog.module.css b/src/features/settings/dialog/SettingsDialog.module.css
index a385f206e..fe7a2c1d0 100644
--- a/src/features/settings/dialog/SettingsDialog.module.css
+++ b/src/features/settings/dialog/SettingsDialog.module.css
@@ -11,15 +11,12 @@
}
.sidebar {
- flex: none;
- width: 240px;
display: flex;
flex-direction: column;
min-height: 0;
- border-right: 1px solid var(--border);
}
.search {
- margin: 10px;
+ margin: 7px 5px 6px;
}
.tree {
flex: 1;
@@ -57,11 +54,11 @@
}
.main {
- flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
min-height: 0;
+ container: settings-content / inline-size;
}
.loading {
flex: 1;
@@ -95,6 +92,13 @@
color: var(--fg-strong);
font-weight: 600;
}
+.crumb:last-child {
+ min-width: 0;
+}
+.crumb > span {
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
.crumb {
display: inline-flex;
align-items: center;
diff --git a/src/features/settings/dialog/SettingsDialog.tsx b/src/features/settings/dialog/SettingsDialog.tsx
index 0ae1ab284..f8655a514 100644
--- a/src/features/settings/dialog/SettingsDialog.tsx
+++ b/src/features/settings/dialog/SettingsDialog.tsx
@@ -18,6 +18,9 @@ import {
IconButton,
SearchField,
Spinner,
+ SplitGroup,
+ SplitHandle,
+ SplitPanel,
Tree,
type DialogButton,
type TreeHandle,
@@ -277,8 +280,8 @@ export function SettingsLayout() {
}
return (
- <div className={styles.layout}>
- <div className={styles.sidebar}>
+ <SplitGroup id="settings" orientation="horizontal" storageKey="openidea.settings.layout" className={styles.layout}>
+ <SplitPanel id="navigation" defaultSize="240px" minSize="160px" maxSize="40%" className={styles.sidebar}>
<SearchField
data-autofocus
className={styles.search}
@@ -332,8 +335,9 @@ export function SettingsLayout() {
)}
/>
</div>
- </div>
- <div className={styles.main}>
+ </SplitPanel>
+ <SplitHandle aria-label={tx("Settings pages")} />
+ <SplitPanel id="content" minSize="60%" className={styles.main}>
<PageHost
node={current}
page={current?.page}
@@ -343,8 +347,8 @@ export function SettingsLayout() {
history={history}
key={current?.key ?? groupKey("")}
/>
- </div>
- </div>
+ </SplitPanel>
+ </SplitGroup>
);
}
diff --git a/src/features/settings/pages/Behavior.module.css b/src/features/settings/pages/Behavior.module.css
index 5a928ac14..981e85275 100644
--- a/src/features/settings/pages/Behavior.module.css
+++ b/src/features/settings/pages/Behavior.module.css
@@ -1,22 +1,23 @@
-/* Rows under the Theme row (IDEA indents them under the label column). */
-.indented {
- display: flex;
- flex-direction: column;
- padding-left: 20px;
-}
.inline {
display: inline-flex;
align-items: center;
+ gap: var(--space-2);
margin-left: 8px;
padding: 0 4px;
border-radius: var(--radius-row);
}
+.themeSelect {
+ flex: 1 1 120px;
+ min-width: min(120px, 100%);
+ max-width: 180px;
+}
.matched {
background: color-mix(in srgb, var(--warning) 8%, transparent);
}
.note {
+ flex: 1 1 220px;
color: var(--fg-subtle);
- white-space: nowrap;
+ overflow-wrap: anywhere;
}
.popupBody {
display: flex;
@@ -92,6 +93,12 @@
min-width: 0;
}
+@container settings-content (max-width: 580px) {
+ .grid {
+ grid-template-columns: minmax(0, 1fr);
+ }
+}
+
.radios {
display: flex;
flex-wrap: wrap;
diff --git a/src/features/settings/pages/behavior.tsx b/src/features/settings/pages/behavior.tsx
index 38563adb4..bef2db8b0 100644
--- a/src/features/settings/pages/behavior.tsx
+++ b/src/features/settings/pages/behavior.tsx
@@ -16,7 +16,7 @@ import { SCHEMES as EDITOR_SCHEMES, listSchemes, customSchemes } from "@/platfor
import { formatTimestamp } from "@/platform/dateFormat";
import { Checkbox, IconButton, Input, Popup, type SelectOption, T } from "@/ui";
import { NOTIFICATION_GROUPS } from "@/workbench/notificationStore";
-import { ColorSwatches, NumberInput, Row, SearchLabel, Select, Toggle } from "../components/Form";
+import { ColorSwatches, FormGroup, NumberInput, Row, SearchLabel, Select, Toggle } from "../components/Form";
import { useLabelMatch, useSetting } from "../components/context";
import {
IDLE_LIMITS,
@@ -48,7 +48,7 @@ function BoundToggle({ k, label, hint, disabled }: { k: string; label: string; h
}
function Indented({ children }: { children: ReactNode }) {
- return <div className={styles.indented}>{children}</div>;
+ return <FormGroup indented>{children}</FormGroup>;
}
// ---------------------------------------------------------------------------
@@ -95,6 +95,7 @@ function ThemeRow() {
onChange={setTheme}
onPreview={preview}
aria-label="Theme"
+ className={styles.themeSelect}
disabled={sync}
/>
<span className={clsx(styles.inline, matched && styles.matched)}>
@@ -107,17 +108,17 @@ function ThemeRow() {
}}
label={<SearchLabel text="Sync with OS" />}
/>
+ <IconButton
+ ref={gear}
+ icon="settings"
+ size="small"
+ title="Preferred themes for light and dark OS mode"
+ aria-label="Preferred themes"
+ disabled={!sync}
+ aria-expanded={open}
+ onClick={() => setOpen((v) => !v)}
+ />
</span>
- <IconButton
- ref={gear}
- icon="settings"
- size="small"
- title="Preferred themes for light and dark OS mode"
- aria-label="Preferred themes"
- disabled={!sync}
- aria-expanded={open}
- onClick={() => setOpen((v) => !v)}
- />
<Popup
open={open}
onClose={() => setOpen(false)}
diff --git a/src/features/settings/pages/editor/Editor.module.css b/src/features/settings/pages/editor/Editor.module.css
index 1146b6435..e8515e205 100644
--- a/src/features/settings/pages/editor/Editor.module.css
+++ b/src/features/settings/pages/editor/Editor.module.css
@@ -33,6 +33,9 @@
align-items: center;
gap: 6px;
}
+.inlineLabel::after {
+ content: ":";
+}
.inlineNumber {
width: 64px;
}
@@ -120,10 +123,13 @@
.fontFamily {
display: flex;
align-items: center;
+ flex-wrap: wrap;
gap: 8px;
+ min-width: 0;
}
.fontSelect {
- min-width: 240px;
+ width: 240px;
+ max-width: 100%;
}
.previewTitle {
margin: 18px 0 6px;
diff --git a/src/features/settings/pages/editor/font.tsx b/src/features/settings/pages/editor/font.tsx
index 52ae9c948..0324acc59 100644
--- a/src/features/settings/pages/editor/font.tsx
+++ b/src/features/settings/pages/editor/font.tsx
@@ -4,7 +4,7 @@
*/
import { FontPicker } from "../../components/FontPicker";
-import { useState } from "react";
+import { useId, useState } from "react";
import { Checkbox, type SelectOption, T } from "@/ui";
import { monoFontFamily } from "@/platform/fonts";
import { NumberInput, Row, SearchLabel, Select } from "../../components/Form";
@@ -40,15 +40,24 @@ function FontRow() {
function SizeRow() {
const [size, setSize] = useSetting<number>("editor.fontSize");
const [line, setLine] = useSetting<number>("editor.lineHeight");
+ const lineId = useId();
return (
- <>
- <Row label="Size">
- <NumberInput value={size} onChange={setSize} {...LIMITS.fontSize} aria-label="Size" unit="px" />
- </Row>
- <Row label="Line height">
- <NumberInput value={line} onChange={setLine} {...LIMITS.lineHeight} aria-label="Line height" unit="px" />
- </Row>
- </>
+ <Row label="Size">
+ <NumberInput value={size} onChange={setSize} {...LIMITS.fontSize} aria-label="Size" unit="px" />
+ <span className={styles.inline}>
+ <label htmlFor={lineId} className={styles.inlineLabel}>
+ <SearchLabel text="Line height" />
+ </label>
+ <NumberInput
+ id={lineId}
+ value={line}
+ onChange={setLine}
+ {...LIMITS.lineHeight}
+ aria-label="Line height"
+ unit="px"
+ />
+ </span>
+ </Row>
);
}