mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 23:56:05 -10:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2234ac7941 | ||
|
|
32de3d0bf8 | ||
|
|
380de4ecd5 |
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("keeps breakpoint details editable when the dialog gets narrow", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 500, height: 480 });
|
||||
await page.evaluate(async () => {
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const storeModule = "/src/features/debugger/breakpoints/store.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
const { addBreakpoint } = await import(/* @vite-ignore */ storeModule);
|
||||
addBreakpoint("/dev/acme-api/CheckInternationalSettlementBeforeDispatch.java", 7, {
|
||||
condition: "amount > 100",
|
||||
});
|
||||
addBreakpoint("/dev/acme-api/Receipt.java", 4);
|
||||
await executeAction("debug.viewBreakpoints");
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Breakpoints" });
|
||||
const list = dialog.getByRole("listbox", { name: "All breakpoints" });
|
||||
const condition = dialog.locator('input[aria-label="Condition"]');
|
||||
await expect(condition).toHaveValue("amount > 100");
|
||||
await expect.poll(async () => (await condition.boundingBox())?.width ?? 0).toBeGreaterThanOrEqual(240);
|
||||
await expect(dialog.getByRole("button", { name: "Done", exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await condition.fill("amount > 250");
|
||||
await dialog.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check();
|
||||
await dialog.getByRole("textbox", { name: "Evaluate and log", exact: true }).fill("total: {amount}");
|
||||
const first = list.getByRole("option", { name: /CheckInternationalSettlementBeforeDispatch\.java:8/ });
|
||||
await expect(first.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await list.getByRole("option", { name: /Receipt\.java:5/ }).click();
|
||||
await expect(condition).toHaveValue("");
|
||||
await first.click();
|
||||
await expect(condition).toHaveValue("amount > 250");
|
||||
await expect(dialog.getByRole("textbox", { name: "Evaluate and log", exact: true })).toHaveValue("total: {amount}");
|
||||
|
||||
await page.setViewportSize({ width: 1080, height: 760 });
|
||||
const divider = dialog.locator('[data-separator][aria-orientation="vertical"]');
|
||||
await expect(divider).toBeInViewport();
|
||||
const oldWidth = (await list.boundingBox())!.width;
|
||||
const handle = (await divider.boundingBox())!;
|
||||
await page.mouse.move(handle.x + handle.width / 2, handle.y + handle.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(handle.x + 60, handle.y + handle.height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await list.boundingBox())?.width ?? 0).toBeGreaterThan(oldWidth + 20);
|
||||
await expect(condition).toHaveValue("amount > 250");
|
||||
const request = dialog.getByRole("textbox", { name: "Part of a request URL" });
|
||||
await request.scrollIntoViewIfNeeded();
|
||||
await expect(request).toBeInViewport({ ratio: 1 });
|
||||
await dialog.getByRole("button", { name: "Done", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
});
|
||||
@@ -24,7 +24,10 @@ describe("the Breakpoints dialog", () => {
|
||||
});
|
||||
|
||||
const dialog = () => screen.getByRole("dialog", { name: "Breakpoints" });
|
||||
const row = (name: string) => within(within(dialog()).getByLabelText("All breakpoints")).getByText(name);
|
||||
const row = (location: string) =>
|
||||
within(within(dialog()).getByRole("listbox", { name: "All breakpoints" })).getByRole("option", {
|
||||
name: (name) => name.includes(`Enable breakpoint at ${location}`),
|
||||
});
|
||||
const condition = () => within(dialog()).getByLabelText("Condition") as HTMLInputElement;
|
||||
/** A row's mouse click as the list sees it: mousedown selects, click (with its count) activates. */
|
||||
const clickRow = (name: string, detail: number) => {
|
||||
@@ -37,8 +40,8 @@ describe("the Breakpoints dialog", () => {
|
||||
render(<DebuggerOverlays />);
|
||||
clickRow("main.py:7", 1);
|
||||
expect(openFile).not.toHaveBeenCalled();
|
||||
// Its details show beside the list.
|
||||
expect(within(dialog()).getAllByText("main.py:7")).toHaveLength(2);
|
||||
expect(row("main.py:7").getAttribute("aria-selected")).toBe("true");
|
||||
expect(condition().value).toBe("");
|
||||
clickRow("main.py:3", 2);
|
||||
expect(openFile).toHaveBeenCalledWith(path, { selection: { line: 2, col: 0 } });
|
||||
});
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
.section {
|
||||
flex: none;
|
||||
max-height: 40%;
|
||||
overflow: auto;
|
||||
border-top: 1px solid var(--border-popup);
|
||||
padding: 6px 12px 8px;
|
||||
display: flex;
|
||||
|
||||
@@ -88,36 +88,46 @@
|
||||
}
|
||||
|
||||
/* breakpoints dialog */
|
||||
.bpDialog {
|
||||
display: flex;
|
||||
height: 420px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.bpListPane {
|
||||
width: 360px;
|
||||
flex: none;
|
||||
.bpWindow [data-dialog-body] {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid var(--border-popup);
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.bpDialog {
|
||||
flex: 1 1 420px;
|
||||
}
|
||||
|
||||
.bpListHeader {
|
||||
height: var(--h-header);
|
||||
min-height: var(--h-header);
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-1-5);
|
||||
padding: 0 8px 0 12px;
|
||||
padding: var(--space-0-5) var(--space-2);
|
||||
border-bottom: 1px solid var(--border-popup);
|
||||
}
|
||||
|
||||
.bpListActions {
|
||||
display: flex;
|
||||
gap: var(--space-1);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.bpList {
|
||||
flex: 1;
|
||||
flex: 1 0 calc(2 * var(--h-list-row));
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.bpAuxiliary {
|
||||
flex: 0 1 auto;
|
||||
max-height: 42%;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.bpRow,
|
||||
.chooserRow {
|
||||
display: flex;
|
||||
@@ -135,6 +145,31 @@
|
||||
color: var(--fg-emphasis);
|
||||
}
|
||||
|
||||
.bpLocation {
|
||||
display: inline-flex;
|
||||
min-width: 0;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.bpRow .bpName,
|
||||
.bpLocation .bpName {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.bpLine {
|
||||
flex: none;
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.bpRow > svg {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.bpDir {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
@@ -156,14 +191,29 @@
|
||||
.bpDetail {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.detail {
|
||||
padding: 12px 14px;
|
||||
padding: var(--space-3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.detail .bpTitle {
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
}
|
||||
|
||||
.detail :is(.bpFile, .bpLocation) {
|
||||
flex: 1 1 12ch;
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.detail .label {
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.statusLine {
|
||||
@@ -245,9 +295,6 @@
|
||||
}
|
||||
|
||||
.exceptions {
|
||||
flex: none;
|
||||
max-height: 40%;
|
||||
overflow: auto;
|
||||
border-top: 1px solid var(--border-popup);
|
||||
padding: 6px 12px 8px;
|
||||
display: flex;
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
Fragment,
|
||||
useEffect,
|
||||
useId,
|
||||
useLayoutEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
@@ -13,7 +14,23 @@ import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
import { call, commands, type AttachableProcess, type RunConfig, type Variable } from "@/platform/ipc";
|
||||
import { maybeEditorService, notifications } from "@/workbench/contributions";
|
||||
import { Button, Checkbox, Dialog, Icon, IconButton, Input, Kbd, List, Menu, Popup, Toggle, T } from "@/ui";
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
Icon,
|
||||
IconButton,
|
||||
Input,
|
||||
Kbd,
|
||||
List,
|
||||
Menu,
|
||||
Popup,
|
||||
SplitGroup,
|
||||
SplitHandle,
|
||||
SplitPanel,
|
||||
Toggle,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { isConditional, suspends, type BreakpointEntry } from "../breakpoints/model";
|
||||
import {
|
||||
removeAllBreakpoints,
|
||||
@@ -373,6 +390,15 @@ type DialogRow =
|
||||
| ({ type: "line"; key: string } & BpRow)
|
||||
| { type: "special"; key: string; bp: SpecialBreakpoint };
|
||||
|
||||
function BreakpointLocation({ path, line }: { path: string; line: number }) {
|
||||
return (
|
||||
<span className={styles.bpLocation} title={`${path}:${line + 1}`}>
|
||||
<span className={styles.bpName}>{basename(path)}</span>
|
||||
<span className={styles.bpLine}>:{line + 1}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function BreakpointsDialog() {
|
||||
const state = useOverlays((s) => s.breakpoints);
|
||||
const byFile = useBreakpoints((s) => s.byFile);
|
||||
@@ -407,6 +433,18 @@ function BreakpointsDialog() {
|
||||
// Enter on Done and a click on a row don't blur them.
|
||||
const commitRef = useRef<(() => void) | null>(null);
|
||||
const open = !!state;
|
||||
const layout = useRef<HTMLDivElement>(null);
|
||||
const [stacked, setStacked] = useState(false);
|
||||
useLayoutEffect(() => {
|
||||
const el = layout.current;
|
||||
if (!open || !el) return;
|
||||
const update = () => setStacked(el.clientWidth > 0 && el.clientWidth < 560);
|
||||
update();
|
||||
if (typeof ResizeObserver === "undefined") return;
|
||||
const observer = new ResizeObserver(update);
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, [open]);
|
||||
const current = items.find((r) => r.key === (selected ?? state?.id)) ?? items[0];
|
||||
const close = () => {
|
||||
commitRef.current?.();
|
||||
@@ -430,28 +468,38 @@ function BreakpointsDialog() {
|
||||
open={open}
|
||||
onClose={close}
|
||||
title="Breakpoints"
|
||||
className={styles.bpWindow}
|
||||
width={760}
|
||||
minWidth={400}
|
||||
minHeight={340}
|
||||
resizable="both"
|
||||
aria-label="Breakpoints"
|
||||
buttons={[{ label: "Done", role: "default", onClick: close }]}
|
||||
>
|
||||
<div className={styles.bpDialog}>
|
||||
<div className={styles.bpListPane}>
|
||||
<SplitGroup
|
||||
elementRef={layout}
|
||||
orientation={stacked ? "vertical" : "horizontal"}
|
||||
storageKey={stacked ? "openidea.debug.breakpoints.stacked" : "openidea.debug.breakpoints.split"}
|
||||
className={styles.bpDialog}
|
||||
>
|
||||
<SplitPanel id="breakpoint-list" defaultSize={stacked ? "42%" : "35%"} minSize={stacked ? "34%" : "216px"}>
|
||||
<div className={styles.bpListHeader}>
|
||||
<Toggle checked={muted} onChange={setMuted} label="Mute breakpoints" />
|
||||
<div className={styles.spacer} />
|
||||
<IconButton
|
||||
icon="plus"
|
||||
title="Add Method Breakpoint"
|
||||
size="small"
|
||||
onClick={() => setSelected(addMethodBreakpoint("").id)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="trash"
|
||||
title="Remove All Breakpoints"
|
||||
size="small"
|
||||
disabled={!items.length}
|
||||
onClick={removeAll}
|
||||
/>
|
||||
<div className={styles.bpListActions}>
|
||||
<IconButton
|
||||
icon="plus"
|
||||
title="Add Method Breakpoint"
|
||||
size="small"
|
||||
onClick={() => setSelected(addMethodBreakpoint("").id)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="trash"
|
||||
title="Remove All Breakpoints"
|
||||
size="small"
|
||||
disabled={!items.length}
|
||||
onClick={removeAll}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<List
|
||||
items={rows}
|
||||
@@ -486,7 +534,9 @@ function BreakpointsDialog() {
|
||||
aria-label={tx`Enable ${specialTitle(r.bp)}`}
|
||||
/>
|
||||
<Icon name={r.bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<span className={styles.bpName}>{specialTitle(r.bp)}</span>
|
||||
<span className={styles.bpName} title={specialTitle(r.bp)}>
|
||||
{specialTitle(r.bp)}
|
||||
</span>
|
||||
{r.bp.path && (
|
||||
<span className={styles.bpDir}>
|
||||
{basename(r.bp.path)}
|
||||
@@ -520,9 +570,7 @@ function BreakpointsDialog() {
|
||||
}
|
||||
aria-hidden
|
||||
/>
|
||||
<span className={styles.bpName}>
|
||||
{basename(r.path)}:{r.bp.line + 1}
|
||||
</span>
|
||||
<BreakpointLocation path={r.path} line={r.bp.line} />
|
||||
<span className={styles.bpDir}>{relativePath(root, r.path)}</span>
|
||||
{isConditional(r.bp) && <span className={styles.bpCond}>{suspends(r.bp) ? "if" : "log"}</span>}
|
||||
{r.bp.temporary && (
|
||||
@@ -534,17 +582,22 @@ function BreakpointsDialog() {
|
||||
);
|
||||
}}
|
||||
/>
|
||||
<ExceptionBreakpoints open={open} />
|
||||
<EventBreakpointsSection />
|
||||
</div>
|
||||
<div className={styles.bpDetail}>
|
||||
{current?.type === "line" ? (
|
||||
<BreakpointDetail key={current.key} row={current} onGo={() => goTo(current)} commitRef={commitRef} />
|
||||
) : current?.type === "special" ? (
|
||||
<SpecialDetail key={current.key} bp={current.bp} onGo={() => goTo(current)} commitRef={commitRef} />
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.bpAuxiliary}>
|
||||
<ExceptionBreakpoints open={open} />
|
||||
<EventBreakpointsSection />
|
||||
</div>
|
||||
</SplitPanel>
|
||||
<SplitHandle />
|
||||
<SplitPanel id="breakpoint-detail" minSize={stacked ? "42%" : "284px"}>
|
||||
<div className={styles.bpDetail}>
|
||||
{current?.type === "line" ? (
|
||||
<BreakpointDetail key={current.key} row={current} onGo={() => goTo(current)} commitRef={commitRef} />
|
||||
) : current?.type === "special" ? (
|
||||
<SpecialDetail key={current.key} bp={current.bp} onGo={() => goTo(current)} commitRef={commitRef} />
|
||||
) : null}
|
||||
</div>
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -610,10 +663,7 @@ function BreakpointDetail({
|
||||
return (
|
||||
<div className={styles.detail}>
|
||||
<div className={styles.bpTitle}>
|
||||
<span className={styles.bpFile}>
|
||||
{basename(path)}:{bp.line + 1}
|
||||
</span>
|
||||
<div className={styles.spacer} />
|
||||
<BreakpointLocation path={path} line={bp.line} />
|
||||
<Button size="small" variant="ghost" onClick={onGo}>
|
||||
<T>Go to Source</T>
|
||||
</Button>
|
||||
@@ -664,8 +714,9 @@ function SpecialDetail({
|
||||
<div className={styles.detail}>
|
||||
<div className={styles.bpTitle}>
|
||||
<Icon name={bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<span className={styles.bpFile}>{specialTitle(bp)}</span>
|
||||
<div className={styles.spacer} />
|
||||
<span className={styles.bpFile} title={specialTitle(bp)}>
|
||||
{specialTitle(bp)}
|
||||
</span>
|
||||
{bp.path && (
|
||||
<Button size="small" variant="ghost" onClick={onGo}>
|
||||
<T>Go to Source</T>
|
||||
|
||||
Reference in new issue
Block a user