Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 836e781e7c fix(editor): align the Find Usages source preview 2026-11-23 10:41:42 +08:00
l0ng-ai c4e08a9676 fix(gradle): keep task descriptions in row tooltips (#5286)
Gradle task rows give the available space beside the icon to the task name. The full description appears in the row tooltip, where assistive technology can also read it.
2026-11-23 10:06:57 +08:00
l0ng-ai 2c0b76c9e6 fix(editor): align the line separator menu (#5284)
- Give the line separator picker a standard menu heading. List Windows, Unix and macOS, and classic Mac OS from top to bottom.
- Use the localized platform names and escaped newline sequences in the menu. The status bar still shows the abbreviation and the menu checks the current format.
2026-11-23 09:48:46 +08:00
l0ng-ai 4d1f51c607 fix(editor): integrate usage access filters into the toolbars (#5283)
- Put read and write filters alongside the other actions in Show Usages and in the Find Usages tool window. Both results areas use the space previously occupied by a separate filter row.
- Keep the two buttons together as the popup narrows. The side toolbar can scroll when the tool window is short.
2026-11-23 09:26:05 +08:00
l0ng-ai 2215239ecb fix(editor): put the pin in the editor tab action slot (#5282)
- Put the pin in a pinned editor tab's action slot so the filename has more room. The pin follows the left or right placement and can unpin the tab directly.
- Use the same Unpin action in Hidden Editor Tabs. A modified pinned tab shows its unsaved marker beside the pin.
2026-11-23 09:23:25 +08:00
l0ng-ai 43eeb080be fix(run): expand multiline configuration fields in place (#5267)
Multiline run configuration fields now keep the Expand button inside the field. The larger editor opens next to the field so the configuration stays in view. It can be resized, scrolls long arguments horizontally, and applies edits through OK or Ctrl/⌘+Enter.
2026-11-23 09:16:39 +08:00
28 змінених файлів з 564 додано та 103 видалено

No files matched your search

+37
Переглянути файл
@@ -88,3 +88,40 @@ test("a close button on the left keeps a narrow slot before the icon", async ({
const slot = await box(closeOf(selected));
expect(slot.x + slot.width).toBeLessThanOrEqual(label.x + 0.5);
});
test("a pinned editor tab uses the close slot and can be unpinned from it", async ({ workbench: page }) => {
await openFromTree(page, "README.md");
await openFromTree(page, "build.gradle.kts");
const strip = page.getByRole("tablist", { name: "Editor tabs" });
const unpinned = strip.getByRole("tab", { name: "build.gradle.kts", exact: true });
const pinned = strip.getByRole("tab", { name: "build.gradle.kts Pinned", exact: true });
const menu = page.getByRole("menu", { name: "Context menu" });
const pin = async () => {
await unpinned.click({ button: "right" });
await menu.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
};
await pin();
const unpin = pinned.locator("..").getByRole("button", { name: "Unpin Tab", exact: true });
for (const closeButtonPosition of ["right", "left"]) {
await setTabs(page, { closeButtonPosition });
await expect(closeOf(pinned)).toHaveCount(0);
const tab = await box(pinned.locator(".."));
const action = await box(unpin);
const label = await box(pinned.locator(":scope > span"));
const inset = closeButtonPosition === "left" ? action.x - tab.x : tab.x + tab.width - action.x - action.width;
expect(inset).toBeCloseTo(2, 0);
expect(action.width).toBeCloseTo(16, 0);
if (closeButtonPosition === "left") expect(action.x + action.width).toBeLessThanOrEqual(label.x);
else expect(action.x).toBeGreaterThanOrEqual(label.x + label.width);
}
await setTabs(page, { showCloseButton: false });
await unpin.click();
await expect(unpinned).toHaveAttribute("aria-selected", "true");
await expect(closeOf(unpinned)).toHaveCount(0);
await pin();
await pinned.click({ button: "middle" });
await expect(pinned).toHaveCount(0);
});
+60
Переглянути файл
@@ -1,6 +1,66 @@
import type { Locator } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
test("Find Usages places read and write filters with the other actions", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async () => {
const modulePath = "/src/features/code-insight/usages.ts";
const { useUsagesPopup } = await import(modulePath);
const path = "/dev/acme-api/src/SettlementService.ts";
const lines = ["const current = settlement;", "settlement = next;"];
window.__ipc.handlers.fs_read_text = () => lines.join("\n");
useUsagesPopup.setState({
open: true,
anchor: { x: 100, y: 150 },
symbol: "settlement",
loading: false,
scope: "project",
groups: [
{
path,
usages: lines.map((text, line) => ({
path,
line,
col: text.indexOf("settlement"),
endCol: text.indexOf("settlement") + "settlement".length,
text,
access: line === 0 ? "read" : "write",
})),
},
],
});
});
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
const read = { name: "Show read accesses", exact: true };
const write = { name: "Show write accesses", exact: true };
const actions = popup.getByRole("button", { name: "Show Preview", exact: true }).locator("..");
await expect(popup.getByRole("option")).toHaveCount(2);
for (const width of [1120, 540]) {
await page.setViewportSize({ width, height: 640 });
expect(await actions.getByRole("toolbar", { name: "Usage access filters", exact: true }).count()).toBe(1);
await expect(actions.getByRole("button", read)).toBeInViewport({ ratio: 1 });
await expect(actions.getByRole("button", write)).toBeInViewport({ ratio: 1 });
}
await actions.getByRole("button", write).click();
await expect(popup.getByRole("option")).toHaveCount(1);
await popup.getByRole("button", { name: /Open in Find Window/ }).click();
const view = page.getByRole("region", { name: "Find Usages", exact: true });
const toolbar = view.getByRole("toolbar", { name: "Usages actions", exact: true });
const readButton = toolbar.getByRole("button", read);
const writeButton = toolbar.getByRole("button", write);
await expect(readButton).toHaveAttribute("aria-pressed", "true");
await expect(writeButton).toHaveAttribute("aria-pressed", "false");
const a = (await readButton.boundingBox())!;
const b = (await writeButton.boundingBox())!;
expect(a.x).toBeCloseTo(b.x, 0);
expect(b.y).toBeGreaterThanOrEqual(a.y + a.height);
await expect(view.locator("mark")).toHaveCount(1);
await writeButton.click();
await expect(view.locator("mark")).toHaveCount(2);
});
async function checkSize(icon: Locator, size = 16) {
const dimensions = await icon.evaluate((node) => {
const style = getComputedStyle(node);
+24
Переглянути файл
@@ -12,6 +12,30 @@ const names = [
"InvoicePublisher.ts",
];
test("a pinned editor tab can be unpinned from the hidden tabs list", async ({ workbench: page }) => {
await page.setViewportSize({ width: 700, height: 650 });
await page.evaluate(async (first) => {
const module = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ module);
await editorService().openFile(`/dev/acme-api/${first}`);
}, names[0]!);
const strip = page.getByRole("tablist", { name: "Editor tabs" });
const tab = strip.getByRole("tab", { name: names[0], exact: true });
await tab.click({ button: "right" });
await page.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
await page.evaluate(async (files) => {
const module = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ module);
for (const name of files) await editorService().openFile(`/dev/acme-api/${name}`);
}, names.slice(1));
await strip.evaluate((element) => (element.scrollLeft = element.scrollWidth));
await page.getByRole("button", { name: "Show Hidden Tabs" }).click();
const row = page.getByRole("grid", { name: "Hidden Editor Tabs" }).getByRole("row").filter({ hasText: names[0]! });
await expect(row.getByRole("button", { name: "Close Tab", exact: true })).toHaveCount(0);
await row.getByRole("button", { name: "Unpin Tab", exact: true }).click();
await expect(tab).toHaveCount(1);
});
test("the editor overflow lists clipped tabs and can close or open one without touching visible tabs", async ({
workbench: page,
}) => {
+4
Переглянути файл
@@ -83,6 +83,10 @@ test("links independent Gradle roots, runs identical task paths in their own bui
});
const tasks = tree.getByRole("treeitem", { name: /^assemble\b/ });
await expect(tasks).toHaveCount(2);
expect(await tasks.allTextContents()).toEqual(["assemble", "assemble"]);
for (const task of await tasks.all()) {
await expect(task).toHaveAccessibleDescription("Assembles this project");
}
await page.screenshot({ path: info.outputPath("gradle-two-roots.png"), animations: "disabled" });
await tasks.nth(0).dblclick();
+63
Переглянути файл
@@ -2,6 +2,69 @@ import type { Page } from "@playwright/test";
import type { BeforeLaunchTask } from "../src/bindings";
import { expect, test } from "./fixtures";
test("expands VM options beside the field and returns edited text to the configuration", async ({
workbench: page,
}) => {
const original = "-Xmx512m\n-Ddemo.endpoint=https://example.test/" + "long-segment/".repeat(12);
await page.evaluate(async (vmOptions) => {
const path = "/src/features/run/store.ts";
const { useRun } = await import(/* @vite-ignore */ path);
useRun.setState({
configs: [
{
id: "layout:jvm",
name: "Catalog service",
kind: "application",
command: "java",
args: ["example.Catalog"],
params: { mainClass: "example.Catalog", vmOptions },
env: {},
cwd: null,
detected: false,
isTest: false,
debugAdapter: "java-debug",
},
],
editTarget: "layout:jvm",
loaded: true,
editorOpen: true,
});
}, original);
const config = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
const field = config.getByRole("textbox", { name: "VM options", exact: true });
const expanded = page.getByRole("dialog", { name: "VM options", exact: true });
const editor = expanded.getByRole("textbox", { name: "VM options", exact: true });
for (const width of [1100, 560]) {
await page.setViewportSize({ width, height: 760 });
await field.scrollIntoViewIfNeeded();
await field.press("Shift+Enter");
await expect(editor).toBeFocused();
await expect
.poll(async () => {
const source = (await field.boundingBox())!;
const popup = (await expanded.boundingBox())!;
const gap = Math.min(Math.abs(popup.y - source.y - source.height), Math.abs(source.y - popup.y - popup.height));
return popup.x >= 0 && popup.x + popup.width <= width && gap <= 6;
})
.toBe(true);
await expect.poll(() => editor.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeGreaterThan(0);
await editor.fill("-Xmx1g");
await editor.press("Escape");
await expect(expanded).toBeHidden();
await expect(field).toBeFocused();
await expect(field).toHaveValue(original);
}
const expand = config.getByRole("button", { name: "Expand (⇧⏎)", exact: true });
await expand.click();
await expect(editor).toBeFocused();
await editor.fill(original + "\n-Ddemo.mode=local");
await editor.press("Control+Enter");
await expect(expanded).toBeHidden();
await expect(field).toHaveValue(original + "\n-Ddemo.mode=local");
});
async function openConfigurations(page: Page, target?: string, beforeLaunch?: BeforeLaunchTask[]) {
await page.evaluate(
async ({ target, beforeLaunch }) => {
+36
Переглянути файл
@@ -1,5 +1,41 @@
import { expect, openFromTree, test } from "./fixtures";
test("the line separator menu has a heading and keeps the current choice visible", async ({ workbench: page }) => {
await openFromTree(page, "build.gradle.kts");
const status = page.locator('[data-status-item="editor.lineEnding"]').getByRole("button");
const menu = page.getByRole("menu", { name: /^Line Separator$/i });
const windows = "Windows (\\r\\n)";
const unix = "Unix and macOS (\\n)";
const classic = "Classic Mac OS (\\r)";
await expect(status).toHaveText("LF");
await status.click();
const heading = menu.locator("..").getByText("Line Separator", { exact: true });
expect(await heading.count()).toBe(1);
await expect(heading).toHaveCSS("font-size", "13px");
await expect(menu.locator('[role^="menuitem"]')).toHaveText([windows, unix, classic]);
await page.setViewportSize({ width: 540, height: 540 });
await expect(heading).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitemcheckbox", { name: unix, checked: true })).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitem", { name: windows })).toBeFocused();
await page.keyboard.press("Enter");
await expect(status).toHaveText("CRLF");
await status.click();
await expect(menu.getByRole("menuitemcheckbox", { name: windows, checked: true })).toBeFocused();
await page.keyboard.press("ArrowDown");
await page.keyboard.press("Enter");
await expect(status).toHaveText("LF");
await page.evaluate(async () => {
const path = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ path)).setLocale("zh");
});
await status.click();
const translated = page.getByRole("menu", { name: "行分隔符", exact: true });
await expect(translated.getByRole("menuitem", { name: "Windows 换行 (\\r\\n)", exact: true })).toBeVisible();
});
test("status bar uses its row height and widget insets in both densities", async ({ workbench: page }) => {
const editor = await openFromTree(page, "build.gradle.kts");
const bar = page.locator('footer[aria-label="Status bar"]');
+95
Переглянути файл
@@ -0,0 +1,95 @@
import type { Page } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
async function setEditorMetrics(page: Page, fontSize: number, lineHeight: number) {
await page.evaluate(
async ({ fontSize, lineHeight }) => {
const projectModule = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { settings, project } = useProject.getState();
const current = settings ?? project?.settings;
if (!current) throw new Error("Expected project settings");
useProject.setState({ settings: { ...current, editor: { ...current.editor, fontSize, lineHeight } } });
},
{ fontSize, lineHeight },
);
}
async function openResults(page: Page) {
await page.setViewportSize({ width: 1120, height: 720 });
await stubDesktop(page);
await setEditorMetrics(page, 20, 34);
await page.evaluate(async () => {
const lines = Array.from({ length: 1240 }, () => "");
lines[1233] = " record(orderTotal);";
lines[1237] = " return orderTotal;";
window.__ipc.handlers.fs_read_text = () => lines.join("\n");
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
await executeAction("find.showUsageResults", {
symbol: "orderTotal",
locations: [
{
path: "/dev/acme-api/src/orderTotals.ts",
range: { start: { line: 1233, col: 9 }, end: { line: 1233, col: 19 } },
},
{
path: "/dev/acme-api/src/orderTotals.ts",
range: { start: { line: 1237, col: 9 }, end: { line: 1237, col: 19 } },
},
],
});
});
const view = page.getByRole("region", { name: "Find Usages", exact: true });
await view.getByRole("treeitem").filter({ hasText: "1234" }).click();
const preview = view.getByRole("region", { name: "Preview", exact: true });
await expect(preview.locator("mark")).toHaveCount(2);
return { view, preview };
}
test("Find Usages preview follows editor line height and fits long line numbers", async ({ workbench: page }) => {
const { preview } = await openResults(page);
await expect(preview).toHaveCSS("font-size", "20px");
await expect(preview).toHaveCSS("line-height", "34px");
const number = preview.getByText("1234", { exact: true });
const gutter = await number.evaluate((element) => {
const range = document.createRange();
range.selectNodeContents(element);
const text = range.getBoundingClientRect();
const box = element.getBoundingClientRect();
return { textInset: text.left - box.left, width: box.width };
});
expect(gutter.textInset).toBeGreaterThanOrEqual(1);
await expect(number).toBeInViewport({ ratio: 0.98 });
expect((await preview.getByText("999", { exact: true }).boundingBox())!.width).toBeCloseTo(gutter.width, 0);
await page.setViewportSize({ width: 560, height: 720 });
await setEditorMetrics(page, 20, 39);
await expect(preview).toHaveCSS("line-height", "39px");
await expect(number).toBeInViewport({ ratio: 0.98 });
});
test("Find Usages starts with equal panes and keeps a separate saved size for each orientation", async ({
workbench: page,
}) => {
const { view } = await openResults(page);
const divider = view.locator('[id="usages-preview-split"]').getByRole("separator");
await expect(divider).toHaveAttribute("aria-valuenow", "50");
await divider.press("ArrowRight");
await expect(divider).not.toHaveAttribute("aria-valuenow", "50");
const horizontal = (await divider.getAttribute("aria-valuenow"))!;
await page.setViewportSize({ width: 560, height: 720 });
await expect(divider).toHaveAttribute("aria-orientation", "horizontal");
await expect(divider).toHaveAttribute("aria-valuenow", "50");
await divider.press("ArrowDown");
await expect(divider).not.toHaveAttribute("aria-valuenow", "50");
const vertical = (await divider.getAttribute("aria-valuenow"))!;
await page.setViewportSize({ width: 1120, height: 720 });
await expect(divider).toHaveAttribute("aria-orientation", "vertical");
await expect(divider).toHaveAttribute("aria-valuenow", horizontal);
await page.setViewportSize({ width: 560, height: 720 });
await expect(divider).toHaveAttribute("aria-valuenow", vertical);
});
-4
Переглянути файл
@@ -143,10 +143,6 @@
gap: var(--space-0-5);
padding: 0 6px 0 8px;
}
.pin {
color: var(--fg-muted);
margin-left: -2px;
}
.deprecated {
text-decoration-line: line-through;
}
+3 -9
Переглянути файл
@@ -38,7 +38,6 @@ import { useFileColors } from "@/workbench/fileColors";
import { EmptyEditor } from "@/workbench/EditorArea";
import {
EmptyState,
Icon,
IconButton,
Menu,
SplitGroup,
@@ -216,7 +215,6 @@ function PaneView({ paneId }: { paneId: string }) {
? (gitRevisionOf(t.input.path)?.revision.slice(0, 8) ?? basename(dirname(t.input.path)))
: null;
const kindMark = tabTrailing(t.input, kinds);
const pin = t.pinned ? <Icon name="pin" size={11} className={styles.pin} label="Pinned" /> : null;
const file = t.input.kind === "file" && t.input.path ? files.get(t.input.path) : undefined;
const title = markModified && dirty[i] ? `*${name}` : name;
const prefix = t.input.kind === "file" && dupe ? (dupe.endsWith("/") ? dupe : `${dupe}/`) : null;
@@ -242,6 +240,7 @@ function PaneView({ paneId }: { paneId: string }) {
: tabIcon(t.input, kinds)
: undefined,
italic: t.preview,
pinned: t.pinned,
error: t.input.kind === "file" && errors[i],
modified: dirty[i],
// IDEA: hiding the close button is visual only. Keep close gestures
@@ -252,13 +251,7 @@ function PaneView({ paneId }: { paneId: string }) {
tints[i] || (fileColors && t.input.kind === "file" && t.input.path ? fileColors(t.input.path) : undefined),
tintStrength: tints[i] ? undefined : "var(--file-tint-strength)",
tooltip: virtualTooltip(t.input) ?? (showFullPathOnHover ? (t.input.path ?? name) : undefined),
trailing:
kindMark || pin ? (
<>
{kindMark}
{pin}
</>
) : undefined,
trailing: kindMark,
};
});
}, [
@@ -369,6 +362,7 @@ function PaneView({ paneId }: { paneId: string }) {
onSelect={(id) => ctrl.activate(paneId, id)}
onClose={(id) => void ctrl.closeTab(paneId, id)}
onCloseOthers={(id) => void ctrl.closeOthers(paneId, id)}
onTogglePin={(id) => ctrl.togglePin(paneId, id)}
closeOnShiftClick
onDoubleClick={(id) => {
// IDEA: a preview tab becomes a regular one; any other tab maximizes the editor.
+11 -6
Переглянути файл
@@ -417,6 +417,11 @@ export function CaretStatus() {
}
const EOL_LABEL: Record<LineEnding, string> = { lf: "LF", crLf: "CRLF", cr: "CR" };
const EOL_CHOICES: { id: LineEnding; label: string }[] = [
{ id: "crLf", label: "Windows (\\r\\n)" },
{ id: "lf", label: "Unix and macOS (\\n)" },
{ id: "cr", label: "Classic Mac OS (\\r)" },
];
export function LineEndingStatus() {
const meta = useActiveMeta();
@@ -454,12 +459,12 @@ export function LineEndingStatus() {
onClose={() => setOpen(false)}
anchor={ref}
placement="top-end"
aria-label="Line separator"
items={(["lf", "crLf", "cr"] as LineEnding[]).map((le) => ({
id: le,
label: `${EOL_LABEL[le]} – ${le === "lf" ? "Unix and macOS (\\n)" : le === "crLf" ? "Windows (\\r\\n)" : "Classic Mac OS (\\r)"}`,
checked: meta.lineEnding === le ? true : undefined,
run: () => choose(le),
title="Line Separator"
items={EOL_CHOICES.map(({ id, label }) => ({
id,
label,
checked: meta.lineEnding === id ? true : undefined,
run: () => choose(id),
}))}
/>
</>
+3 -4
Переглянути файл
@@ -317,14 +317,12 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
? `(${node.dependency.scope}${node.dependency.optional ? ", optional" : ""})`
: node.kind === "dependency" && node.dependency.optional
? "(optional)"
: node.kind === "task"
? node.task.description
: null;
: null;
const skipped =
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
return (
<span className={styles.row} title={node.kind === "task" ? (node.task.description ?? undefined) : undefined}>
<span className={styles.row}>
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{nodeLabel(node)}
@@ -475,6 +473,7 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
roots={roots}
getKey={(n) => n.key}
getLabel={nodeLabel}
getTooltip={(n) => (n.kind === "task" ? (n.task.description ?? undefined) : undefined)}
getChildren={getChildren}
isExpandable={(n) => !!getChildren(n)?.length}
expanded={expanded}
+4 -2
Переглянути файл
@@ -2,6 +2,8 @@
display: flex;
align-items: center;
gap: var(--space-0-5);
padding: 3px 6px;
flex-shrink: 0;
flex: none;
}
.vertical {
flex-direction: column;
}
+9 -2
Переглянути файл
@@ -1,4 +1,6 @@
import { create } from "zustand";
import clsx from "clsx";
import { useTx } from "@/platform/i18n";
import { IconButton } from "@/ui";
import type { Usage } from "./usages";
import styles from "./UsageAccessFilter.module.css";
@@ -45,11 +47,16 @@ export function filterUsageAccess(items: readonly Usage[], options: UsageAccessO
export const supportsUsageAccess = (items: readonly Usage[]) => items.some((u) => u.access && u.access !== "unknown");
export function UsageAccessFilter({ items }: { items: readonly Usage[] }) {
export function UsageAccessFilter({ items, vertical }: { items: readonly Usage[]; vertical?: boolean }) {
const tx = useTx();
const options = useUsageAccessOptions();
if (!supportsUsageAccess(items)) return null;
return (
<div className={styles.toolbar} role="toolbar" aria-label="Usage access filters">
<div
className={clsx(styles.toolbar, vertical && styles.vertical)}
role={vertical ? "group" : "toolbar"}
aria-label={tx("Usage access filters")}
>
<IconButton
icon="show-read-access"
size="small"
+1 -1
Переглянути файл
@@ -176,6 +176,7 @@ function UsagesPopupInner() {
</span>
</span>
<div className={styles.actions}>
<UsageAccessFilter items={all} />
{scope && (
<Select<UsageScope>
variant="ghost"
@@ -213,7 +214,6 @@ function UsagesPopupInner() {
</button>
</div>
</div>
<UsageAccessFilter items={all} />
{note && (
<div className={styles.note} data-testid="usages-note">
{note}
+4 -2
Переглянути файл
@@ -17,8 +17,11 @@
gap: var(--space-0-5);
padding: 4px 0;
border-right: 1px solid var(--border);
overflow-y: auto;
scrollbar-width: none;
}
.toolbarSep {
flex: none;
width: 16px;
height: 1px;
margin: 3px 0;
@@ -66,7 +69,6 @@
flex: 1;
min-height: 0;
}
.body > [role="toolbar"],
.body > .summary {
flex: 0 0 auto;
}
@@ -157,7 +159,7 @@
flex-direction: column;
font-family: var(--font-mono);
font-size: var(--fs-code);
line-height: 1.45;
line-height: var(--lh-code);
}
.sourcePreview .sourceText[role="region"] {
font: inherit;
+14 -3
Переглянути файл
@@ -284,11 +284,11 @@ export function UsagesView() {
<IconButton icon="arrow-up" action="navigate.prevOccurrence" size="small" iconSize={16} />
<IconButton icon="arrow-down" action="navigate.nextOccurrence" size="small" iconSize={16} />
<span className={styles.toolbarSep} />
<UsageAccessFilter items={allUsages} vertical />
<IconButton icon="expand-all" title="Expand All" size="small" iconSize={16} onClick={() => setAll(false)} />
<IconButton icon="collapse-all" title="Collapse All" size="small" iconSize={16} onClick={() => setAll(true)} />
</div>
<div className={styles.body} onKeyDown={onKeyDown}>
<UsageAccessFilter items={allUsages} />
{!search.loading && !search.error && search.scope === "project" && (
<div className={styles.summary}>
<T>Usages in Project Files</T>
@@ -406,6 +406,8 @@ export function useUsagesHeaderMenu(): MenuItem[] {
];
}
const DEFAULT_PREVIEW_LAYOUT = { usages: 50, preview: 50 };
function UsagesSplit({ preview, children }: { preview: ReactNode; children: ReactNode }) {
const show = useUsagesOptions((s) => s.preview);
const frame = useRef<HTMLDivElement>(null);
@@ -427,12 +429,13 @@ function UsagesSplit({ preview, children }: { preview: ReactNode; children: Reac
orientation={stacked ? "vertical" : "horizontal"}
id="usages-preview-split"
storageKey={stacked ? "openidea.usages.previewSplit.vertical" : "openidea.usages.previewSplit"}
defaultLayout={DEFAULT_PREVIEW_LAYOUT}
>
<SplitPanel id="usages" minSize={stacked ? "30%" : 160} className={styles.panel}>
{children}
</SplitPanel>
<SplitHandle />
<SplitPanel id="preview" minSize={stacked ? "30%" : 160} defaultSize="45%" className={styles.panel}>
<SplitPanel id="preview" minSize={stacked ? "30%" : 160} className={styles.panel}>
{preview}
</SplitPanel>
</SplitGroup>
@@ -455,13 +458,21 @@ function UsagesPreview({ node }: { node: Node | null }) {
return (group?.usages ?? []).map((u) => ({ line: u.line, ranges: [[u.col, u.endCol] as const] }));
}, [usage, search?.groups]);
return (
<div className={styles.sourcePreview} style={{ fontFamily, fontSize: settings?.fontSize ?? undefined }}>
<div
className={styles.sourcePreview}
style={{
fontFamily,
fontSize: settings?.fontSize ?? undefined,
lineHeight: settings?.lineHeight != null ? `${settings.lineHeight}px` : undefined,
}}
>
<SourcePreview
path={usage?.path ?? null}
line={usage?.line ?? 0}
highlights={highlights}
load={previewText}
colorize={previewColors}
editorLayout
className={styles.sourceText}
/>
</div>
+1 -1
Переглянути файл
@@ -53,7 +53,7 @@ it("shows a plain count for unclassified searches after a Java access mode was s
});
const view = render(<UsagesView />);
expect(screen.getByText("2 results")).toBeInTheDocument();
expect(screen.queryByRole("toolbar", { name: "Usage access filters" })).toBeNull();
expect(screen.queryByRole("group", { name: "Usage access filters" })).toBeNull();
view.unmount();
useUsageAccessOptions.setState({ read: true, write: true });
useUsages.setState({ tabs: [], active: null });
+64 -34
Переглянути файл
@@ -1,7 +1,8 @@
import { useState } from "react";
import { useRef, useState, type RefObject } from "react";
import clsx from "clsx";
import { useTx } from "@/platform/i18n";
import { Dialog, IconButton } from "@/ui";
import { isImeKey } from "@/platform/ime";
import { Button, IconButton, Popup } from "@/ui";
import styles from "./Run.module.css";
/**
@@ -25,9 +26,10 @@ export function ExpandableTextarea({
onChange: (value: string) => void;
}) {
const tx = useTx();
const fieldRef = useRef<HTMLDivElement>(null);
const [expanded, setExpanded] = useState(false);
return (
<div className={styles.textareaWithButton}>
<div ref={fieldRef} className={styles.textareaWithButton}>
<textarea
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
aria-label={tx(label)}
@@ -43,58 +45,86 @@ export function ExpandableTextarea({
}
}}
/>
<IconButton icon="expand-all" size="small" iconSize={14} title="Expand (⇧⏎)" onClick={() => setExpanded(true)} />
<IconButton
icon="expand-all"
size="small"
iconSize={14}
title="Expand (⇧⏎)"
aria-haspopup="dialog"
aria-expanded={expanded}
onClick={() => setExpanded(!expanded)}
/>
{expanded && (
<ExpandedTextDialog label={label} value={value} onOk={onChange} onClose={() => setExpanded(false)} />
<ExpandedTextPopup
anchor={fieldRef}
label={tx(label)}
value={value}
onOk={onChange}
onClose={() => setExpanded(false)}
/>
)}
</div>
);
}
function ExpandedTextDialog({
function ExpandedTextPopup({
anchor,
label,
value,
onOk,
onClose,
}: {
anchor: RefObject<HTMLDivElement | null>;
label: string;
value: string;
onOk: (value: string) => void;
onClose: () => void;
}) {
const tx = useTx();
const [text, setText] = useState(value);
const apply = () => {
if (text !== value) onOk(text);
onClose();
};
return (
<Dialog
<Popup
open
title={tx(label)}
anchor={anchor}
aria-label={label}
className={styles.expandedEditor}
onClose={onClose}
width={720}
trapFocus
matchWidth
closeOnDeactivate={false}
resizable="both"
minWidth={360}
minHeight={220}
buttons={[
{
label: "OK",
role: "default",
onClick: () => {
if (text !== value) onOk(text);
onClose();
},
},
{ label: "Cancel", role: "cancel" },
]}
minWidth={240}
minHeight={160}
>
<textarea
className={clsx(styles.textarea, styles.expandedTextarea)}
aria-label={tx(label)}
spellCheck={false}
wrap="off"
rows={14}
value={text}
autoFocus
onChange={(e) => setText(e.target.value)}
/>
</Dialog>
<div
className={styles.expandedEditorBody}
onKeyDown={(e) => {
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || isImeKey(e.nativeEvent))
return;
e.preventDefault();
e.stopPropagation();
apply();
}}
>
<textarea
className={clsx(styles.textarea, styles.expandedTextarea)}
aria-label={label}
spellCheck={false}
wrap="off"
value={text}
data-autofocus
onChange={(e) => setText(e.target.value)}
/>
<div className={styles.expandedEditorActions}>
<Button onClick={onClose}>Cancel</Button>
<Button variant="primary" onClick={apply}>
OK
</Button>
</div>
</div>
</Popup>
);
}
+26 -10
Переглянути файл
@@ -922,28 +922,44 @@
outline: none;
}
.textareaWithButton {
display: flex;
align-items: flex-start;
gap: var(--space-1-5);
position: relative;
min-width: 0;
}
.textareaWithButton > textarea {
flex: 1;
min-width: 0;
display: block;
width: 100%;
padding-inline-end: calc(var(--space-3) + var(--space-4));
}
.textareaWithButton > button {
flex-shrink: 0;
position: absolute;
inset-block-start: var(--space-1);
inset-inline-end: var(--space-1);
}
.expandedEditor {
width: 512px;
height: 272px;
}
.expandedEditorBody {
display: flex;
flex-direction: column;
height: 100%;
padding: var(--space-2);
gap: var(--space-2);
}
/* One visual line per line of text: a long argument scrolls instead of wrapping. */
.expandedTextarea {
width: 100%;
height: 100%;
min-height: 160px;
box-sizing: border-box;
flex: 1;
min-height: 0;
resize: none;
white-space: pre;
overflow: auto;
}
.expandedEditorActions {
display: flex;
justify-content: flex-end;
flex: none;
gap: var(--space-2);
}
.textarea:focus {
box-shadow: inset 0 0 0 1px var(--focus-ring);
}
+5
Переглянути файл
@@ -970,6 +970,10 @@
"Tag value": "Tag value",
"Attribute": "Attribute",
"Contents differ only in line separators": "Contents differ only in line separators",
"Line Separator": "Line Separator",
"Windows (\\r\\n)": "Windows (\\r\\n)",
"Unix and macOS (\\n)": "Unix and macOS (\\n)",
"Classic Mac OS (\\r)": "Classic Mac OS (\\r)",
"Cannot remove a worktree containing the open project.": "Cannot remove a worktree containing the open project.",
"Delete Remote Branches": "Delete Remote Branches",
"Delete the {length} branches '{names}' on the remote? The remote-tracking branches are removed as well.": "Delete the {length} branches '{names}' on the remote? The remote-tracking branches are removed as well.",
@@ -1583,6 +1587,7 @@
"Read the project's resolved Maven and Gradle dependencies": "Read the project's resolved Maven and Gradle dependencies",
"Resolved Dependencies": "Resolved Dependencies",
"Usages of {symbol}": "Usages of {symbol}",
"Usage access filters": "Usage access filters",
"Read the clipboard's text and images when you run one of its commands": "Read the clipboard's text and images when you run one of its commands",
"Output: {channel}": "Output: {channel}",
"You can close this tab.": "You can close this tab.",
+1
Переглянути файл
@@ -5146,6 +5146,7 @@
"Days on which files changed; older revisions are removed when a project opens.": "按文件有更改的天数计算;打开项目时会删除更早的修订。",
"Language of menus and dialogs; untranslated text stays in English.": "菜单和对话框的语言;未翻译的文本保持英文。",
"Unix and macOS (\\n)": "Unix 和 macOS (\\n)",
"Windows (\\r\\n)": "Windows 换行 (\\r\\n)",
"Classic Mac OS (\\r)": "经典 Mac OS (\\r)",
"Encoding of new files; decodes project files that are not valid UTF-8 and have no BOM.": "新文件的编码;也用于解码不是有效 UTF-8 且没有 BOM 的项目文件。",
"Stored in the IDE; used by projects without their own scheme.": "存储在 IDE 中;供没有自己方案的项目使用。",
+9 -5
Переглянути файл
@@ -22,6 +22,7 @@ interface Props {
onSelect: (id: string) => void;
onCloseTab?: (id: string) => void;
onCloseOthers?: (id: string) => void;
onTogglePin?: (id: string) => void;
onDismiss: () => void;
}
@@ -34,6 +35,7 @@ export function HiddenTabsPopup({
onSelect,
onCloseTab,
onCloseOthers,
onTogglePin,
onDismiss,
}: Props) {
const tr = useGivenTx();
@@ -131,20 +133,22 @@ export function HiddenTabsPopup({
className={styles.list}
renderItem={(item) => {
if (!item) return null;
const close = Boolean(onCloseTab && item.closable !== false && item.showCloseButton !== false);
const unpin = item.pinned && onTogglePin;
const close = onCloseTab && item.closable !== false && item.showCloseButton !== false;
const action = (
<div role="gridcell" className={styles.action}>
{item.modified && <span className={styles.modified} aria-label={tr("Modified")} />}
{close && (
{(unpin || close) && (
<IconButton
icon="close"
title="Close Tab"
icon={unpin ? "pin" : "close"}
title={unpin ? "Unpin Tab" : "Close Tab"}
size="small"
tabIndex={-1}
onMouseDown={(event) => event.preventDefault()}
onClick={(event) => {
event.stopPropagation();
if (event.altKey && onCloseOthers) onCloseOthers(item.id);
if (unpin) unpin(item.id);
else if (event.altKey && onCloseOthers) onCloseOthers(item.id);
else onCloseTab!(item.id);
}}
/>
+2 -2
Переглянути файл
@@ -41,8 +41,8 @@
flex: none;
position: sticky;
left: 0;
width: 48px;
padding-right: 12px;
width: var(--source-preview-gutter-width, 48px);
padding-right: var(--space-3);
text-align: right;
color: var(--fg-gutter);
background-color: var(--bg-app);
+34 -4
Переглянути файл
@@ -9,7 +9,7 @@
* Usages. Files beyond `MAX_PARSE` stay plain rather than colouring the window
* with the wrong block-comment context.
*/
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";
import clsx from "clsx";
import { T } from "./T";
import { tokenSpans, type SourceToken } from "./tokenSpans";
@@ -46,6 +46,8 @@ export interface SourcePreviewProps {
version?: number;
/** Stable (module-level) syntax colouring; without it lines stay plain. */
colorize?: SourceColorizer;
/** Fit the gutter to the line numbers and keep the selected line visible when the pane resizes. */
editorLayout?: boolean;
className?: string;
}
@@ -56,6 +58,7 @@ export function SourcePreview({
load,
version = 0,
colorize,
editorLayout,
className,
}: SourcePreviewProps) {
const [text, setText] = useState<{ path: string; lines: string[] } | null>(null);
@@ -160,6 +163,7 @@ export function SourcePreview({
lines={current.lines}
tokensByLine={tokensByLine}
highlights={highlights}
editorLayout={editorLayout}
className={className}
/>
);
@@ -176,6 +180,7 @@ function PreviewBody({
lines,
tokensByLine,
highlights,
editorLayout,
className,
}: {
path: string;
@@ -183,6 +188,7 @@ function PreviewBody({
lines: string[];
tokensByLine: Map<number, SourceToken[]> | null;
highlights: readonly SourceHighlight[];
editorLayout?: boolean;
className?: string;
}) {
const scrollRef = useRef<HTMLDivElement>(null);
@@ -192,8 +198,21 @@ function PreviewBody({
useLayoutEffect(() => {
const box = scrollRef.current;
const el = box?.querySelector<HTMLElement>(`[data-line="${line}"]`);
if (box && el) box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.offsetHeight / 2;
}, [line, path, lines]);
if (!box || !el) return;
const center = () => {
box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.offsetHeight / 2;
};
center();
if (!editorLayout || typeof ResizeObserver === "undefined") return;
const observer = new ResizeObserver(() => {
if (el.offsetTop < box.scrollTop || el.offsetTop + el.offsetHeight > box.scrollTop + box.clientHeight) {
center();
}
});
observer.observe(box);
observer.observe(el);
return () => observer.disconnect();
}, [editorLayout, line, path, lines]);
const byLine = new Map(highlights.map((h) => [h.line, h.ranges]));
const start = Math.max(0, line - WINDOW);
@@ -214,7 +233,18 @@ function PreviewBody({
}
return (
<div ref={scrollRef} className={clsx(styles.preview, className)} role="region" aria-label={tx("Preview")}>
<pre className={styles.pre}>{rows}</pre>
<pre
className={styles.pre}
style={
editorLayout
? ({
"--source-preview-gutter-width": `calc(${String(lines.length).length}ch + var(--space-4))`,
} as CSSProperties)
: undefined
}
>
{rows}
</pre>
</div>
);
}
+11 -1
Переглянути файл
@@ -137,6 +137,16 @@
.unpin {
color: var(--fg-muted);
}
.pinModified {
position: absolute;
top: calc(50% - 7px);
inset-inline-end: 1px;
width: var(--space-1);
height: var(--space-1);
border-radius: 50%;
background: var(--accent);
pointer-events: none;
}
.tab:hover .close,
.tab:where([data-context-menu-open]) .close,
.selected .close,
@@ -301,7 +311,7 @@
width: auto;
margin: 0;
}
.editor:not(.vertical) .close {
.editor:not(.vertical) :is(.close, .unpin) {
width: 16px;
}
.editor:not(.vertical) .closeSlot .modified {
+19
Переглянути файл
@@ -199,6 +199,25 @@ describe("Tabs interactions", () => {
expect(handles[0]!.togglePinSelected()).toBe(false);
});
it("shows the modified marker in a pinned editor tab's action slot", () => {
const onTogglePin = vi.fn();
render(
<Tabs
variant="editor"
items={[{ id: "b", label: "B", text: "B", pinned: true, modified: true }]}
activeId="b"
onSelect={() => {}}
onClose={() => {}}
onTogglePin={onTogglePin}
/>,
);
const unpin = screen.getByRole("button", { name: "Unpin Tab" });
expect(within(unpin.parentElement!).getByLabelText("Modified")).toBeVisible();
expect(screen.getByRole("tab", { name: "B Pinned" })).toBeVisible();
fireEvent.click(unpin);
expect(onTogglePin).toHaveBeenCalledWith("b");
});
it("a vertical strip moves with ↑/↓, shows actions above the tabs and has no overflow dropdown", () => {
const onSelect = vi.fn();
render(
+21 -13
Переглянути файл
@@ -34,10 +34,7 @@ export interface TabItem {
text?: string;
icon?: IconName | (string & {});
closable?: boolean;
/**
* Pinned (IDEA's content tabs): with `onTogglePin`, an Unpin button takes the close
* button's place, and the strip's close gestures leave the tab alone.
*/
/** With `onTogglePin`, the tab shows Unpin in the action slot. */
pinned?: boolean;
/**
* Visual only: hide this tab's close button without disabling its close
@@ -129,7 +126,7 @@ export interface TabsProps {
onClose?: (id: string) => void;
/** Alt+click on a close button (IDEA: close all other tabs). */
onCloseOthers?: (id: string) => void;
/** Pin / Unpin Tab on the selected tab, from the container (a tool window's content tabs). */
/** Toggle the pinned state of a tab. */
onTogglePin?: (id: string) => void;
/** Shift+left-click a tab closes it (editor tabs; plain clicks still select). */
closeOnShiftClick?: boolean;
@@ -183,6 +180,7 @@ export function Tabs({
...aria
}: TabsProps) {
const vertical = orientation === "vertical";
const protectPinned = variant !== "editor" && !!onTogglePin;
const given = useGivenTx();
const scrollRef = useRef<HTMLDivElement>(null);
const tabRefs = useRef(new Map<string, HTMLButtonElement>());
@@ -194,17 +192,17 @@ export function Tabs({
const [dragging, setDragging] = useState<string | null>(null);
const register = useContext(TabStripRegistry);
const latest = useRef({ items, activeId, onClose, onTogglePin });
const latest = useRef({ items, activeId, onClose, onTogglePin, protectPinned });
useLayoutEffect(() => {
latest.current = { items, activeId, onClose, onTogglePin };
latest.current = { items, activeId, onClose, onTogglePin, protectPinned };
});
useEffect(
() =>
register?.({
closeSelected: () => {
const { items, activeId, onClose, onTogglePin } = latest.current;
const { items, activeId, onClose, protectPinned } = latest.current;
const item = items.find((it) => it.id === activeId);
if (!item || !onClose || item.closable === false || (item.pinned && onTogglePin)) return false;
if (!item || !onClose || !canCloseTab(item, protectPinned)) return false;
onClose(item.id);
return true;
},
@@ -341,7 +339,7 @@ export function Tabs({
break;
case "Delete":
case "Backspace":
if (onClose && item.closable !== false && !(item.pinned && onTogglePin)) onClose(item.id);
if (onClose && canCloseTab(item, protectPinned)) onClose(item.id);
else return;
break;
case "Tab":
@@ -399,8 +397,9 @@ export function Tabs({
const pinned = !!onTogglePin && !!item.pinned;
// Whether a tab can be closed at all (gestures and the button). A hidden
// close button is visual only: middle click, Shift+click and Delete still work.
const closable = !!onClose && item.closable !== false && !pinned;
const showClose = closable && item.showCloseButton !== false;
const closable = !!onClose && canCloseTab(item, protectPinned);
const showClose = closable && !pinned && item.showCloseButton !== false;
const pinModified = pinned && variant === "editor" && item.modified;
return (
<div
key={item.id}
@@ -476,6 +475,7 @@ export function Tabs({
id={panelIdPrefix ? `${panelIdPrefix}-tab-${item.id}` : undefined}
aria-controls={panelIdPrefix ? `${panelIdPrefix}-panel-${item.id}` : undefined}
aria-selected={selected}
aria-label={pinned && variant === "editor" && item.text ? `${item.text} ${tx("Pinned")}` : undefined}
tabIndex={selected || (!activeId && index === 0) ? 0 : -1}
className={clsx(styles.tabButton, item.dimmed && styles.dimmed)}
style={item.color ? { color: item.color } : undefined}
@@ -500,7 +500,9 @@ export function Tabs({
{typeof item.label === "string" ? <Given>{item.label}</Given> : item.label}
</span>
{item.trailing}
{item.modified && !showClose && <span className={styles.modified} aria-label={tx("Modified")} />}
{item.modified && !showClose && !pinModified && (
<span className={styles.modified} aria-label={tx("Modified")} />
)}
</button>
{pinned && (
<span className={styles.closeSlot} data-tab-close>
@@ -516,6 +518,7 @@ export function Tabs({
onTogglePin!(item.id);
}}
/>
{pinModified && <span className={styles.pinModified} aria-label={tx("Modified")} />}
</span>
)}
{showClose && (
@@ -564,6 +567,7 @@ export function Tabs({
onSelect={onSelect}
onCloseTab={onClose}
onCloseOthers={onCloseOthers}
onTogglePin={onTogglePin}
onDismiss={closeMenu}
/>
)
@@ -584,6 +588,10 @@ export function Tabs({
);
}
function canCloseTab(item: TabItem, protectPinned: boolean): boolean {
return item.closable !== false && !(protectPinned && item.pinned);
}
/** Scrolls `scroller` horizontally just enough to show all of `child`. */
export function revealHorizontally(scroller: HTMLElement, child: HTMLElement) {
const s = scroller.getBoundingClientRect();
+3
Переглянути файл
@@ -93,6 +93,8 @@ export interface TreeProps<T> {
getIcon?: (node: T, expanded: boolean) => IconName | (string & {}) | undefined;
/** Muted trailing detail (e.g. a path next to the project root); may include styled content. */
getDetail?: (node: T) => ReactNode;
/** Native tooltip and accessible description for a row. */
getTooltip?: (node: T) => string | undefined;
/** Label colour, e.g. VCS status. */
getColor?: (node: T) => string | undefined;
/** Filesystem directory for actions on the focused selection; groups return null. */
@@ -800,6 +802,7 @@ export function Tree<T>(props: TreeProps<T>) {
aria-setsize={positions[v.index]![1]}
aria-expanded={row.expandable ? row.expanded : undefined}
aria-selected={isSelected}
title={props.getTooltip?.(row.node)}
className={clsx(
styles.row,
props.horizontalScroll && styles.wideRow,