mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5675b7979 | ||
|
|
7dff6e1852 | ||
|
|
fc7fa85850 | ||
|
|
7e5a2cf051 |
No files matched your search
@@ -3,6 +3,7 @@
|
||||
* with its frames and variables, and stepping and resuming go back to the adapter. The adapter is
|
||||
* stubbed at the IPC layer; `crates/ide-dap/tests` drives real ones.
|
||||
*/
|
||||
import type { JvmMemoryResult } from "../src/platform/ipc";
|
||||
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const ROOT = "/dev/acme-api";
|
||||
@@ -114,6 +115,83 @@ test("stops at a breakpoint, shows frames and variables, steps and resumes", asy
|
||||
await expect(debug.getByText("CreateOrderRequest(sku='A-1', qty=2)")).toBeHidden();
|
||||
});
|
||||
|
||||
test("Memory gives class filtering the available toolbar width and exposes changed-only filtering", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const rows = [
|
||||
{ name: "OrderCache", instances: 64, deltaInstances: 12 },
|
||||
{ name: "OrderRepository", instances: 16, deltaInstances: 0 },
|
||||
].map((row) => ({ ...row, bytes: row.instances * 16, deltaBytes: null, module: null, ambiguous: false }));
|
||||
const result: JvmMemoryResult = {
|
||||
status: "ready",
|
||||
snapshot: {
|
||||
rows,
|
||||
totalInstances: 80,
|
||||
totalBytes: 1280,
|
||||
javaVersion: "21",
|
||||
takenWhileSuspended: true,
|
||||
hasBaseline: true,
|
||||
elapsedMs: 5,
|
||||
source: "debugger",
|
||||
},
|
||||
};
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ result, id }) => {
|
||||
const caps = { jvmMemory: true, jvmHeap: true };
|
||||
window.__ipc.handlers.debug_capabilities = () => caps;
|
||||
window.__ipc.handlers.debug_jvm_memory_classes = () => result;
|
||||
const debugPath = "/src/features/debugger/state.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugPath);
|
||||
adoptSession(id, { adapter: "java-debug", name: "Billing Service", status: "paused", caps });
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "bottom");
|
||||
layout.setToolWindowSize("bottom", 300);
|
||||
layout.showToolWindow("debug", true);
|
||||
},
|
||||
{ result, id: SESSION },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Memory" }).click();
|
||||
const toolbar = debug.getByRole("toolbar", { name: "Memory", exact: true });
|
||||
const filter = toolbar.getByRole("textbox", { name: "Filter classes" });
|
||||
const options = toolbar.getByRole("button", { name: "View Options" });
|
||||
const grid = debug.getByRole("grid", { name: "Memory", exact: true });
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
expect((await filter.boundingBox())!.width).toBeGreaterThan((await toolbar.boundingBox())!.width / 2);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "right");
|
||||
layout.setToolWindowSize("right", 330);
|
||||
});
|
||||
await expect.poll(async () => (await toolbar.boundingBox())!.width).toBeCloseTo(330, 0);
|
||||
const bar = (await toolbar.boundingBox())!;
|
||||
const gear = (await options.boundingBox())!;
|
||||
const input = (await filter.boundingBox())!;
|
||||
expect(input.width).toBeGreaterThan(bar.width / 2);
|
||||
expect(input.x + input.width).toBeLessThan(gear.x);
|
||||
expect(gear.x + gear.width).toBeLessThanOrEqual(bar.x + bar.width);
|
||||
|
||||
await filter.fill("cache");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await toolbar.getByRole("button", { name: "Clear", exact: true }).click();
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
|
||||
await options.press("Enter");
|
||||
const changed = page.getByRole("menuitemcheckbox", { name: "Changed only" });
|
||||
await expect(changed).not.toBeChecked();
|
||||
await changed.press("Enter");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(options).toBeFocused();
|
||||
await options.press("Enter");
|
||||
await expect(changed).toBeChecked();
|
||||
});
|
||||
|
||||
test("Evaluate keeps a multiline expression and its result visible in a short dialog", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 580, height: 420 });
|
||||
await stubDesktop(page);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { MavenModel } from "../src/platform/ipc";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const maven: MavenModel = {
|
||||
projects: [
|
||||
{
|
||||
pom: "pom.xml",
|
||||
dir: "",
|
||||
groupId: "dev.acme",
|
||||
artifactId: "billing",
|
||||
version: "1.0.0",
|
||||
packaging: "jar",
|
||||
displayName: "Billing",
|
||||
parent: null,
|
||||
modules: [],
|
||||
aggregated: false,
|
||||
plugins: [
|
||||
{
|
||||
groupId: "org.apache.maven.plugins",
|
||||
artifactId: "maven-surefire-plugin",
|
||||
version: "3.2.5",
|
||||
prefix: "surefire",
|
||||
goals: ["test"],
|
||||
},
|
||||
],
|
||||
dependencies: [],
|
||||
profiles: [],
|
||||
javaVersion: 21,
|
||||
command: "mvn",
|
||||
options: [],
|
||||
env: {},
|
||||
},
|
||||
],
|
||||
profiles: [],
|
||||
syncedAt: 1,
|
||||
stale: false,
|
||||
syncError: null,
|
||||
};
|
||||
|
||||
test("Maven plugin rows give the name priority over coordinates in narrow docks", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (maven) => {
|
||||
window.__ipc.handlers.build_model = () => ({ maven, gradle: [] });
|
||||
const buildModule = "/src/features/build-tools/store.ts";
|
||||
const { loadModel, setExpanded } = await import(/* @vite-ignore */ buildModule);
|
||||
await loadModel();
|
||||
setExpanded("maven", new Set(["mvn:pom.xml", "mvn:pom.xml:plugins"]));
|
||||
const dockModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { showToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ dockModule);
|
||||
showToolWindow("maven", true);
|
||||
setToolWindowSize("right", 190);
|
||||
}, maven);
|
||||
|
||||
const tree = page.getByRole("tree", { name: "Maven projects" });
|
||||
const coordinates = "(org.apache.maven.plugins:maven-surefire-plugin:3.2.5)";
|
||||
const plugin = tree.getByRole("treeitem", { name: `surefire ${coordinates}`, exact: true });
|
||||
const name = plugin.getByText("surefire", { exact: true });
|
||||
const metadata = plugin.getByText(coordinates, { exact: true });
|
||||
await expect(name).toBeVisible();
|
||||
await expect(metadata).toHaveAttribute("title", coordinates);
|
||||
const fit = (el: Element) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
|
||||
};
|
||||
expect(await name.evaluate(fit)).toBe(true);
|
||||
expect(await metadata.evaluate(fit)).toBe(false);
|
||||
expect(await metadata.evaluate((el) => getComputedStyle(el).color)).not.toBe(
|
||||
await name.evaluate((el) => getComputedStyle(el).color),
|
||||
);
|
||||
|
||||
await plugin.locator("[data-tree-toggle]").click();
|
||||
await expect(tree.getByRole("treeitem", { name: "surefire:test", exact: true })).toBeVisible();
|
||||
});
|
||||
@@ -75,7 +75,7 @@ for (const locale of ["en", "zh"]) {
|
||||
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"]) {
|
||||
for (const id of ["appearance", "editor.font", "general", "general.httpProxy", "vcs.log"]) {
|
||||
await selectPage(page, id);
|
||||
const body = page.locator("[class*='pageBody']");
|
||||
for (const width of [1000, 784, 640, 520]) {
|
||||
@@ -108,6 +108,31 @@ test("keeps Open project in options within narrow System Settings", async ({ wor
|
||||
expect(overflow).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
test("Git Log settings group display and column options with aligned checkboxes", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await selectPage(page, "vcs.log");
|
||||
const view = dialog.getByRole("region", { name: "View Options" });
|
||||
const columns = dialog.getByRole("region", { name: "Visible columns" });
|
||||
const tagNames = view.getByRole("checkbox", { name: "Show tag names" });
|
||||
const hash = columns.getByRole("checkbox", { name: "Hash" });
|
||||
await expect(view.getByRole("checkbox")).toHaveCount(5);
|
||||
await expect(columns.getByRole("checkbox")).toHaveCount(4);
|
||||
|
||||
for (const width of [1000, 520]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
// Read both rows together once the dialog has finished opening and relaid out.
|
||||
await expect
|
||||
.poll(async () => Math.abs((await tagNames.boundingBox())!.x - (await hash.boundingBox())!.x))
|
||||
.toBeLessThan(0.5);
|
||||
}
|
||||
|
||||
await expect(hash).not.toBeChecked();
|
||||
await hash.focus();
|
||||
await page.keyboard.press("Space");
|
||||
await expect(hash).toBeChecked();
|
||||
});
|
||||
|
||||
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 });
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
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);
|
||||
});
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
mavenRoots,
|
||||
nodeIcon,
|
||||
nodeLabel,
|
||||
pluginCoordinates,
|
||||
profileChecked,
|
||||
withGradleOptions,
|
||||
gradleHasTestTask,
|
||||
@@ -310,6 +311,8 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const plugin = node.kind === "plugin" ? node.plugin : null;
|
||||
const coordinates = plugin && `(${pluginCoordinates(plugin)})`;
|
||||
const detail =
|
||||
node.kind === "profiles" && node.projectRoot
|
||||
? node.projectRoot.split("/").pop()
|
||||
@@ -321,12 +324,24 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
const skipped =
|
||||
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
|
||||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
|
||||
const label = (
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{plugin?.prefix ?? nodeLabel(node)}
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<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)}
|
||||
</span>
|
||||
{coordinates ? (
|
||||
<span className={styles.pluginText}>
|
||||
{label}
|
||||
<span className={styles.detail} title={coordinates}>
|
||||
{coordinates}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
{detail && <span className={styles.detail}>{detail}</span>}
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -96,6 +96,18 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.pluginText {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.pluginText > .label {
|
||||
flex: none;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.profile {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
|
||||
return parts.join(":");
|
||||
}
|
||||
|
||||
export function pluginLabel(p: MavenPlugin): string {
|
||||
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
|
||||
export function pluginCoordinates(p: MavenPlugin): string {
|
||||
return `${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""}`;
|
||||
}
|
||||
|
||||
/** Profile choices in different workspace members are independent. */
|
||||
@@ -363,7 +363,7 @@ export function nodeLabel(node: BuildNode): string {
|
||||
case "plugins":
|
||||
return tx("Plugins");
|
||||
case "plugin":
|
||||
return pluginLabel(node.plugin);
|
||||
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
|
||||
case "goal":
|
||||
return `${node.plugin.prefix}:${node.goal}`;
|
||||
case "dependencies":
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
flex-direction: column;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
line-height: var(--lh-code);
|
||||
line-height: 1.45;
|
||||
}
|
||||
.sourcePreview .sourceText[role="region"] {
|
||||
font: inherit;
|
||||
|
||||
@@ -406,8 +406,6 @@ 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);
|
||||
@@ -429,13 +427,12 @@ 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} className={styles.panel}>
|
||||
<SplitPanel id="preview" minSize={stacked ? "30%" : 160} defaultSize="45%" className={styles.panel}>
|
||||
{preview}
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
@@ -458,21 +455,13 @@ 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,
|
||||
lineHeight: settings?.lineHeight != null ? `${settings.lineHeight}px` : undefined,
|
||||
}}
|
||||
>
|
||||
<div className={styles.sourcePreview} style={{ fontFamily, fontSize: settings?.fontSize ?? undefined }}>
|
||||
<SourcePreview
|
||||
path={usage?.path ?? null}
|
||||
line={usage?.line ?? 0}
|
||||
highlights={highlights}
|
||||
load={previewText}
|
||||
colorize={previewColors}
|
||||
editorLayout
|
||||
className={styles.sourceText}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -241,7 +241,8 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
|
||||
const filter = screen.getByRole("textbox", { name: "筛选类" });
|
||||
expect(filter.getAttribute("placeholder")).toBe("筛选类");
|
||||
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
|
||||
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
|
||||
} finally {
|
||||
await setLocale("en");
|
||||
}
|
||||
@@ -299,10 +300,15 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByText("Cache$Entry")).toBeTruthy();
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
|
||||
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
|
||||
const options = screen.getByRole("button", { name: "View Options" });
|
||||
fireEvent.click(options);
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
|
||||
expect(screen.getByText("Heap$Live")).toBeTruthy();
|
||||
expect(screen.queryByText("Cache$Entry")).toBeNull();
|
||||
expect(screen.queryByText("Dup")).toBeNull();
|
||||
expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
fireEvent.click(options);
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: true })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("sorts by the clicked column and reports it with aria-sort", async () => {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
}
|
||||
|
||||
.filter {
|
||||
flex: 0 1 240px;
|
||||
min-width: 80px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.banner,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Memory tab of the Debug tool window: live instance counts per class of the debugged JVM, and heap capture. */
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
|
||||
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
|
||||
@@ -112,6 +112,8 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
const id = session.id;
|
||||
const entry = useMemory((s) => s.bySession[id]);
|
||||
const query = entry?.query ?? DEFAULT_QUERY;
|
||||
const optionsButton = useRef<HTMLButtonElement>(null);
|
||||
const [optionsOpen, setOptionsOpen] = useState(false);
|
||||
const result = entry?.result ?? null;
|
||||
const snapshot = entry?.snapshot ?? null;
|
||||
const source = snapshot?.source ?? "histogram";
|
||||
@@ -161,17 +163,37 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
disabled={entry?.loading || !canRefresh}
|
||||
/>
|
||||
<HeapCaptureButton session={session} />
|
||||
<Input
|
||||
<SearchField
|
||||
className={styles.filter}
|
||||
value={query.filter}
|
||||
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
|
||||
onChange={(filter) => setMemoryQuery(id, { filter })}
|
||||
placeholder="Filter classes"
|
||||
aria-label="Filter classes"
|
||||
/>
|
||||
<Checkbox
|
||||
checked={query.changedOnly}
|
||||
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
|
||||
label="Changed only"
|
||||
<IconButton
|
||||
ref={optionsButton}
|
||||
icon="settings"
|
||||
title="View Options"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
pressed={query.changedOnly}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={optionsOpen}
|
||||
onClick={() => setOptionsOpen(!optionsOpen)}
|
||||
/>
|
||||
<Menu
|
||||
open={optionsOpen}
|
||||
onClose={() => setOptionsOpen(false)}
|
||||
anchor={optionsButton}
|
||||
placement="bottom-end"
|
||||
aria-label="View Options"
|
||||
items={[
|
||||
{
|
||||
label: "Changed only",
|
||||
checked: query.changedOnly,
|
||||
run: () => setMemoryQuery(id, { changedOnly: !query.changedOnly }),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{backend && (
|
||||
|
||||
@@ -1,22 +1,33 @@
|
||||
.page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
color: var(--fg);
|
||||
display: grid;
|
||||
gap: var(--space-4);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.section {
|
||||
|
||||
.heading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
margin-top: 6px;
|
||||
min-height: var(--h-field);
|
||||
margin: 0 0 var(--space-1);
|
||||
color: var(--fg-strong);
|
||||
font-size: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
.header {
|
||||
color: var(--fg-muted);
|
||||
|
||||
.heading::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
height: 1px;
|
||||
background: var(--border);
|
||||
}
|
||||
.columns {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding-left: 18px;
|
||||
|
||||
.options {
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
padding-inline-start: var(--space-4);
|
||||
}
|
||||
|
||||
.options > label {
|
||||
min-height: var(--h-field);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/** Settings › Version Control › Log: how the Git Log shows references, dates and columns. */
|
||||
import { useId, type ReactNode } from "react";
|
||||
import { Checkbox, T } from "@/ui";
|
||||
import { setLogOptions, useLogOptions, type LogOptions } from "./logOptions";
|
||||
import styles from "./LogSettingsPage.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
|
||||
type Flag = { [K in keyof LogOptions]: LogOptions[K] extends boolean ? K : never }[keyof LogOptions];
|
||||
|
||||
@@ -21,6 +21,18 @@ const COLUMNS: { key: Flag; label: string }[] = [
|
||||
{ key: "showGitHubChecks", label: "GitHub Commit Checks" },
|
||||
];
|
||||
|
||||
function OptionGroup({ title, children }: { title: string; children: ReactNode }) {
|
||||
const heading = useId();
|
||||
return (
|
||||
<section aria-labelledby={heading}>
|
||||
<h2 id={heading} className={styles.heading}>
|
||||
<T>{title}</T>
|
||||
</h2>
|
||||
<div className={styles.options}>{children}</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function LogSettingsPage() {
|
||||
const o = useLogOptions();
|
||||
// Display options only: the log needs no reload.
|
||||
@@ -29,13 +41,8 @@ export function LogSettingsPage() {
|
||||
);
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
{OPTIONS.map(flag)}
|
||||
<section className={styles.section} aria-label={tx("Visible columns")}>
|
||||
<div className={styles.header}>
|
||||
<T>Visible columns:</T>
|
||||
</div>
|
||||
<div className={styles.columns}>{COLUMNS.map(flag)}</div>
|
||||
</section>
|
||||
<OptionGroup title="View Options">{OPTIONS.map(flag)}</OptionGroup>
|
||||
<OptionGroup title="Visible columns">{COLUMNS.map(flag)}</OptionGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3707,5 +3707,7 @@
|
||||
"Previous Rows": "Previous Rows",
|
||||
"Next Rows": "Next Rows",
|
||||
"Previous Columns": "Previous Columns",
|
||||
"Next Columns": "Next Columns"
|
||||
"Next Columns": "Next Columns",
|
||||
"View Options": "View Options",
|
||||
"Visible columns": "Visible columns"
|
||||
}
|
||||
@@ -4751,7 +4751,6 @@
|
||||
"Show commit time rather than author time": "Mostrar fecha y hora de la confirmación en lugar de la del autor",
|
||||
"Show references on the left": "Mostrar referencias a la izquierda",
|
||||
"Visible columns": "Columnas visibles",
|
||||
"Visible columns:": "Columnas visibles:",
|
||||
"Get from Revision": "Obtener de la revisión",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "¿Reemplazar '{path}' con su contenido de la revisión? Los cambios locales se perderán.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "¿Reemplazar {length} archivos con su contenido de la revisión? Los cambios locales en ellos se perderán.",
|
||||
|
||||
@@ -4606,7 +4606,6 @@
|
||||
"Show commit time rather than author time": "Afficher l'heure du commit plutôt que celle de l'auteur",
|
||||
"Show references on the left": "Afficher les références à gauche",
|
||||
"Visible columns": "Colonnes visibles",
|
||||
"Visible columns:": "Colonnes visibles :",
|
||||
"Get from Revision": "Récupérer depuis la révision",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "Remplacer '{path}' par son contenu de la révision ? Ses modifications locales seront perdues.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "Remplacer {length} fichiers par leur contenu de la révision ? Leurs modifications locales seront perdues.",
|
||||
|
||||
@@ -4823,7 +4823,6 @@
|
||||
"Show commit time rather than author time": "작성자 시간 대신 커밋 시간 표시",
|
||||
"Show references on the left": "왼쪽에 참조 표시",
|
||||
"Visible columns": "표시할 열",
|
||||
"Visible columns:": "표시할 열:",
|
||||
"Get from Revision": "리비전에서 가져오기",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "'{path}'을(를) 리비전의 내용으로 바꾸시겠습니까? 해당 파일의 로컬 변경 사항은 손실됩니다.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "파일 {length}개를 리비전의 내용으로 바꾸시겠습니까? 해당 파일의 로컬 변경 사항은 손실됩니다.",
|
||||
|
||||
@@ -4702,7 +4702,6 @@
|
||||
"Show commit time rather than author time": "Pokaż czas zatwierdzenia zamiast czasu autora",
|
||||
"Show references on the left": "Pokaż odnośniki po lewej stronie",
|
||||
"Visible columns": "Widoczne kolumny",
|
||||
"Visible columns:": "Widoczne kolumny:",
|
||||
"Get from Revision": "Pobierz z wersji",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "Zastąpić '{path}' zawartością z tej wersji? Lokalne zmiany w tym pliku zostaną utracone.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "Zastąpić pliki w liczbie {length} ich zawartością z tej wersji? Lokalne zmiany w nich zostaną utracone.",
|
||||
|
||||
@@ -4717,7 +4717,6 @@
|
||||
"Show commit time rather than author time": "Mostrar data/hora do commit em vez da do autor",
|
||||
"Show references on the left": "Mostrar referências à esquerda",
|
||||
"Visible columns": "Colunas visíveis",
|
||||
"Visible columns:": "Colunas visíveis:",
|
||||
"Get from Revision": "Obter da revisão",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "Substituir '{path}' pelo seu conteúdo da revisão? Alterações locais nele serão perdidas.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "Substituir {length} arquivos pelo seu conteúdo da revisão? Alterações locais neles serão perdidas.",
|
||||
|
||||
@@ -7428,7 +7428,6 @@
|
||||
"Show commit time rather than author time": "Yazar zamanı yerine commit zamanını göster",
|
||||
"Show references on the left": "Başvuruları solda göster",
|
||||
"Visible columns": "Görünür sütunlar",
|
||||
"Visible columns:": "Görünür sütunlar:",
|
||||
"Get from Revision": "Revizyondan Al",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "'{path}' dosyası revizyondaki içeriğiyle değiştirilsin mi? Yerel değişiklikleri kaybolacak.",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "{length} dosya revizyondaki içerikleriyle değiştirilsin mi? Yerel değişiklikleri kaybolacak.",
|
||||
|
||||
@@ -5736,7 +5736,6 @@
|
||||
"Show commit time rather than author time": "顯示提交時間而非作者時間",
|
||||
"Show references on the left": "在左側顯示引用",
|
||||
"Visible columns": "可見欄",
|
||||
"Visible columns:": "可見欄:",
|
||||
"Get from Revision": "從修訂取得",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "用修訂中的內容取代「{path}」?其本機更改將遺失。",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "用修訂中的內容取代 {length} 個檔案?它們的本機更改將遺失。",
|
||||
|
||||
@@ -6227,7 +6227,6 @@
|
||||
"Show commit time rather than author time": "显示提交时间而非作者时间",
|
||||
"Show references on the left": "在左侧显示引用",
|
||||
"Visible columns": "可见列",
|
||||
"Visible columns:": "可见列:",
|
||||
"Get from Revision": "从修订获取",
|
||||
"Replace '{path}' with its content from the revision? Local changes to it are lost.": "用修订中的内容替换“{path}”?其本地更改将丢失。",
|
||||
"Replace {length} files with their content from the revision? Local changes to them are lost.": "用修订中的内容替换 {length} 个文件?它们的本地更改将丢失。",
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
flex: none;
|
||||
position: sticky;
|
||||
left: 0;
|
||||
width: var(--source-preview-gutter-width, 48px);
|
||||
padding-right: var(--space-3);
|
||||
width: 48px;
|
||||
padding-right: 12px;
|
||||
text-align: right;
|
||||
color: var(--fg-gutter);
|
||||
background-color: var(--bg-app);
|
||||
|
||||
@@ -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 CSSProperties, type ReactNode } from "react";
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { T } from "./T";
|
||||
import { tokenSpans, type SourceToken } from "./tokenSpans";
|
||||
@@ -46,8 +46,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -58,7 +56,6 @@ export function SourcePreview({
|
||||
load,
|
||||
version = 0,
|
||||
colorize,
|
||||
editorLayout,
|
||||
className,
|
||||
}: SourcePreviewProps) {
|
||||
const [text, setText] = useState<{ path: string; lines: string[] } | null>(null);
|
||||
@@ -163,7 +160,6 @@ export function SourcePreview({
|
||||
lines={current.lines}
|
||||
tokensByLine={tokensByLine}
|
||||
highlights={highlights}
|
||||
editorLayout={editorLayout}
|
||||
className={className}
|
||||
/>
|
||||
);
|
||||
@@ -180,7 +176,6 @@ function PreviewBody({
|
||||
lines,
|
||||
tokensByLine,
|
||||
highlights,
|
||||
editorLayout,
|
||||
className,
|
||||
}: {
|
||||
path: string;
|
||||
@@ -188,7 +183,6 @@ function PreviewBody({
|
||||
lines: string[];
|
||||
tokensByLine: Map<number, SourceToken[]> | null;
|
||||
highlights: readonly SourceHighlight[];
|
||||
editorLayout?: boolean;
|
||||
className?: string;
|
||||
}) {
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
@@ -198,21 +192,8 @@ function PreviewBody({
|
||||
useLayoutEffect(() => {
|
||||
const box = scrollRef.current;
|
||||
const el = box?.querySelector<HTMLElement>(`[data-line="${line}"]`);
|
||||
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]);
|
||||
if (box && el) box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.offsetHeight / 2;
|
||||
}, [line, path, lines]);
|
||||
|
||||
const byLine = new Map(highlights.map((h) => [h.line, h.ranges]));
|
||||
const start = Math.max(0, line - WINDOW);
|
||||
@@ -233,18 +214,7 @@ function PreviewBody({
|
||||
}
|
||||
return (
|
||||
<div ref={scrollRef} className={clsx(styles.preview, className)} role="region" aria-label={tx("Preview")}>
|
||||
<pre
|
||||
className={styles.pre}
|
||||
style={
|
||||
editorLayout
|
||||
? ({
|
||||
"--source-preview-gutter-width": `calc(${String(lines.length).length}ch + var(--space-4))`,
|
||||
} as CSSProperties)
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{rows}
|
||||
</pre>
|
||||
<pre className={styles.pre}>{rows}</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user