mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0329b36604 |
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("gutter breakpoint keeps its location and buttons visible while editing in a short window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 410, height: 340 });
|
||||
await stubDesktop(page);
|
||||
const name = "RecalculateInternationalPaymentsAcrossMultipleRegionalSettlementCyclesAndVerifyReceiptTotals.ts";
|
||||
const path = `/dev/acme-api/${name}`;
|
||||
await page.evaluate(async (path) => {
|
||||
const contributionsModule = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ contributionsModule);
|
||||
await editorService().openFile(path);
|
||||
}, path);
|
||||
await page.locator(".cm-content").evaluate(async (editor, path) => {
|
||||
const view = (editor as HTMLElement & { cmTile: { view: EditorView } }).cmTile.view;
|
||||
const insert = Array.from({ length: 14 }, (_, i) => `const amount${i + 1} = ${i * 10};`).join("\n");
|
||||
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert } });
|
||||
const breakpointsModule = "/src/features/debugger/breakpoints/store.ts";
|
||||
const { addBreakpoint } = await import(/* @vite-ignore */ breakpointsModule);
|
||||
window.__ipc.handlers.debug_set_breakpoints = () => [];
|
||||
addBreakpoint(path, 7, { condition: "amount8 > 50", hitCondition: ">= 3", logMessage: "amount: {amount8}" });
|
||||
}, path);
|
||||
const marker = page.locator(".cm-lineNumbers .cm-gutterElement").filter({ hasText: /^8$/ });
|
||||
const open = () => marker.click({ button: "right" });
|
||||
await open();
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Breakpoint properties" });
|
||||
const done = popup.getByRole("button", { name: "Done", exact: true });
|
||||
const condition = popup.getByLabel("Condition", { exact: true });
|
||||
await expect(condition).toBeFocused();
|
||||
await expect(done).toBeInViewport({ ratio: 1 });
|
||||
const location = popup.getByTitle(`${path}:8`, { exact: true });
|
||||
await expect(location.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(popup.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
|
||||
await condition.fill("amount8 > 60");
|
||||
const log = popup.getByRole("textbox", { name: "Evaluate and log", exact: true });
|
||||
await log.fill("paid: {amount8}");
|
||||
await expect(location).toBeInViewport({ ratio: 1 });
|
||||
await expect(done).toBeInViewport({ ratio: 1 });
|
||||
await done.click();
|
||||
await expect(popup).toBeHidden();
|
||||
|
||||
await open();
|
||||
await expect(condition).toHaveValue("amount8 > 60");
|
||||
await expect(log).toHaveValue("paid: {amount8}");
|
||||
await popup.getByRole("button", { name: /^More/ }).click();
|
||||
const dialog = page.getByRole("dialog", { name: "Breakpoints", exact: true });
|
||||
await expect(dialog.getByLabel("Condition", { exact: true })).toHaveValue("amount8 > 60");
|
||||
});
|
||||
@@ -1,7 +1,3 @@
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 16px;
|
||||
color: var(--fg-faint);
|
||||
@@ -21,12 +17,53 @@
|
||||
}
|
||||
|
||||
/* breakpoint popover */
|
||||
.bpEditor {
|
||||
width: 340px;
|
||||
padding: 10px 12px;
|
||||
.bpPopover {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 400px;
|
||||
overflow: hidden;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.bpPopoverTitle,
|
||||
.bpFooter {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
}
|
||||
|
||||
.bpPopoverTitle {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bpPopoverTitle > svg {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.bpPopoverTitle .bpFile {
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.bpPopoverFields {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
min-height: 0;
|
||||
padding: var(--space-1) var(--space-3) var(--space-2);
|
||||
overflow: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.bpPopoverFields > * {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.bpPopoverFields .label {
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.bpActions {
|
||||
@@ -86,21 +123,27 @@
|
||||
}
|
||||
|
||||
.bpFooter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
margin-top: 2px;
|
||||
flex-wrap: wrap;
|
||||
border-block-start: 1px solid var(--border-popup);
|
||||
}
|
||||
|
||||
.link {
|
||||
.bpFooterButtons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.bpMore {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
color: var(--accent);
|
||||
font-size: var(--fs-ui);
|
||||
cursor: pointer;
|
||||
}
|
||||
.link:hover {
|
||||
.bpMore:hover {
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type CSSProperties,
|
||||
type KeyboardEvent,
|
||||
type MutableRefObject,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
@@ -137,6 +138,62 @@ function BreakpointPopover() {
|
||||
return <BreakpointEditor key={popover.id} path={popover.path} bp={bp} at={popover} focusLog={popover.focusLog} />;
|
||||
}
|
||||
|
||||
function BreakpointPropertiesPopup({
|
||||
at,
|
||||
title,
|
||||
onClose,
|
||||
onRemove,
|
||||
children,
|
||||
}: {
|
||||
at: { x: number; y: number };
|
||||
title: ReactNode;
|
||||
onClose: () => void;
|
||||
onRemove: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Popup
|
||||
open
|
||||
onClose={onClose}
|
||||
anchor={at}
|
||||
placement="bottom-start"
|
||||
trapFocus
|
||||
aria-label="Breakpoint properties"
|
||||
className={styles.bpPopover}
|
||||
>
|
||||
<div className={styles.bpPopoverTitle}>{title}</div>
|
||||
<div className={styles.bpPopoverFields}>{children}</div>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.bpMore}
|
||||
onClick={() => {
|
||||
onClose();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.bpFooterButtons}>
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
onRemove();
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={onClose}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
);
|
||||
}
|
||||
|
||||
function BreakpointEditor({
|
||||
path,
|
||||
bp,
|
||||
@@ -155,49 +212,25 @@ function BreakpointEditor({
|
||||
};
|
||||
|
||||
return (
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeBreakpoint(path, bp.id)}
|
||||
title={
|
||||
<>
|
||||
<span className={styles.bpDot} data-look={bp.enabled ? "on" : "off"} aria-hidden />
|
||||
<span className={styles.bpFile}>
|
||||
{basename(path)}:{bp.line + 1}
|
||||
</span>
|
||||
</div>
|
||||
<BreakpointFields
|
||||
path={path}
|
||||
bp={bp}
|
||||
focus={focusLog ? "log" : "condition"}
|
||||
onEnter={close}
|
||||
commitRef={commitText}
|
||||
/>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => {
|
||||
close();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.spacer} />
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
removeBreakpoint(path, bp.id);
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={close}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
<BreakpointLocation path={path} line={bp.line} />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<BreakpointFields
|
||||
path={path}
|
||||
bp={bp}
|
||||
focus={focusLog ? "log" : "condition"}
|
||||
onEnter={close}
|
||||
commitRef={commitText}
|
||||
/>
|
||||
</BreakpointPropertiesPopup>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -365,66 +398,46 @@ function SpecialEditor({ bp, at }: { bp: SpecialBreakpoint; at: { x: number; y:
|
||||
closeBreakpointPopover();
|
||||
};
|
||||
return (
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeSpecial(bp.id)}
|
||||
title={
|
||||
<>
|
||||
<Icon name={bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<span className={styles.bpFile}>{specialTitle(bp)}</span>
|
||||
</div>
|
||||
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Condition</T>
|
||||
<span className={styles.bpFile} title={specialTitle(bp)}>
|
||||
{specialTitle(bp)}
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={condition}
|
||||
onChange={(e) => setCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
data-autofocus=""
|
||||
aria-label="Condition"
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Hit count</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={hitCondition}
|
||||
onChange={(e) => setHitCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
aria-label="Hit count condition"
|
||||
/>
|
||||
</label>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => {
|
||||
close();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.spacer} />
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
removeSpecial(bp.id);
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={close}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Condition</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={condition}
|
||||
onChange={(e) => setCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
data-autofocus=""
|
||||
aria-label="Condition"
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Hit count</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={hitCondition}
|
||||
onChange={(e) => setHitCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
aria-label="Hit count condition"
|
||||
/>
|
||||
</label>
|
||||
</BreakpointPropertiesPopup>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user