fix(debugger): keep breakpoint details usable in narrow windows (#4605)

The Breakpoints dialog had a fixed list width beside the details, so in narrow windows locations were clipped and the details' controls ran off the dialog. The list and details are now a resizable split that stacks vertically below 560px (each layout remembered), the dialog itself can be resized, and locations show the file name and line with the full path in the tooltip.
This commit is contained in:
l0ng-ai
2026-11-20 06:38:09 +08:00
committed by GitHub
parent 60d335eec0
commit 92ccfac192
5 changed files with 211 additions and 63 deletions
@@ -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;
+66 -19
View File
@@ -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;
+89 -38
View File
@@ -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>