дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-21 09:00:49 +02:00
Порівняти коміти
3
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
f4d8cdffe6 | ||
|
|
439c321fc4 | ||
|
|
da067a4894 |
No files matched your search
@@ -1,75 +0,0 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const functionName = "calculateRegionalSettlementFromExternalOrderBeforeReconciliation";
|
||||
const sourcePath = "/dev/acme-api/build.gradle.kts";
|
||||
|
||||
test("keeps frame sources and the keyboard selection visible in a narrow debug dock", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 540 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ functionName, sourcePath }) => {
|
||||
const debugModule = "/src/features/debugger/state.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const servicesModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
|
||||
const workerFrame = {
|
||||
id: 51,
|
||||
name: "processOrder",
|
||||
path: sourcePath,
|
||||
line: 5,
|
||||
column: 0,
|
||||
presentationHint: null,
|
||||
};
|
||||
window.__ipc.handlers.debug_scopes = () => [];
|
||||
window.__ipc.handlers.debug_stack_trace = () => [workerFrame];
|
||||
adoptSession(91, {
|
||||
name: "Reconciliation",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
stoppedThread: 1,
|
||||
selectedThread: 1,
|
||||
threads: [
|
||||
{ id: 1, name: "MainThread" },
|
||||
{ id: 2, name: "Order worker" },
|
||||
],
|
||||
selectedFrame: 1,
|
||||
frames: Array.from({ length: 32 }, (_, index) => ({
|
||||
id: index + 1,
|
||||
name: index === 0 ? functionName : index === 1 ? "runBatch" : `reconcile(${index})`,
|
||||
path: sourcePath,
|
||||
line: index === 0 ? 41 : index,
|
||||
column: 0,
|
||||
presentationHint: null,
|
||||
})),
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 420);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ functionName, sourcePath },
|
||||
);
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
const thread = debug.getByRole("button", { name: "Thread", exact: true });
|
||||
const frames = debug.getByRole("listbox", { name: "Frames", exact: true });
|
||||
const first = frames.getByRole("option", { selected: true });
|
||||
await expect(first.getByText(functionName, { exact: true })).toBeVisible();
|
||||
expect(await frames.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(first.getByText(":42", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
expect(await first.getByText(/build\.gradle\.kts/).evaluate((el) => el.clientWidth)).toBeGreaterThan(25);
|
||||
const shortName = frames.getByText("runBatch", { exact: true });
|
||||
expect(await shortName.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
await frames.focus();
|
||||
for (let i = 0; i < 25; i++) await page.keyboard.press("ArrowDown");
|
||||
const selected = frames.getByRole("option", { selected: true });
|
||||
await expect(selected.getByText("reconcile(25)", { exact: true })).toBeInViewport({ ratio: 0.95 });
|
||||
expect(await frames.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
|
||||
await thread.click();
|
||||
await page.getByRole("option", { name: "Order worker", exact: true }).click();
|
||||
await expect(thread).toContainText("Order worker");
|
||||
await expect(frames.getByRole("option", { selected: true })).toContainText("processOrder");
|
||||
});
|
||||
@@ -276,23 +276,14 @@ export const openideaTheme = EditorView.theme({
|
||||
},
|
||||
".cm-openidea-laneDeleted": {
|
||||
position: "absolute",
|
||||
left: "-4px",
|
||||
top: "-6px",
|
||||
width: "12px",
|
||||
height: "12px",
|
||||
cursor: "pointer",
|
||||
zIndex: "1",
|
||||
},
|
||||
".cm-openidea-laneDeleted::after": {
|
||||
content: '""',
|
||||
position: "absolute",
|
||||
left: "4px",
|
||||
top: "3px",
|
||||
left: "0",
|
||||
top: "-3px",
|
||||
width: "0",
|
||||
height: "0",
|
||||
borderTop: "3px solid transparent",
|
||||
borderBottom: "3px solid transparent",
|
||||
borderLeft: "6px solid var(--lane-color)",
|
||||
zIndex: "1",
|
||||
},
|
||||
".cm-foldGutter": { width: "16px" },
|
||||
".cm-foldGutter .cm-gutterElement": {
|
||||
|
||||
@@ -292,7 +292,7 @@ describe("debug tool window", () => {
|
||||
expect(screen.getByRole("tab", { name: /main/ })).toBeTruthy();
|
||||
expect(screen.getByRole("tab", { name: "Threads & Variables" })).toBeTruthy();
|
||||
expect(screen.getByRole("tab", { name: "Console" })).toBeTruthy();
|
||||
expect(screen.getByRole("option", { selected: true })).toHaveTextContent("main:12, main.py");
|
||||
expect(screen.getByText(", main.py:12")).toBeTruthy();
|
||||
expect(screen.getByPlaceholderText("Evaluate expression (↩) or add a watch (⇧⌘↩)")).toBeTruthy();
|
||||
expect(await screen.findByText("{int}")).toBeTruthy();
|
||||
expect(screen.getByText("'hi'")).toBeTruthy();
|
||||
|
||||
@@ -102,20 +102,11 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
padding-bottom: var(--space-1);
|
||||
}
|
||||
|
||||
.threadHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
height: 30px;
|
||||
padding: 0 var(--space-1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.threadSelect {
|
||||
max-width: 100%;
|
||||
margin: 0 8px 4px;
|
||||
}
|
||||
|
||||
.frameList {
|
||||
@@ -125,7 +116,7 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
outline: none;
|
||||
padding: var(--space-1) var(--space-1) 0;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.frame {
|
||||
@@ -159,36 +150,24 @@
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.frameText,
|
||||
.frameLabel {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
min-width: 0;
|
||||
}
|
||||
.frameText {
|
||||
flex: 1;
|
||||
}
|
||||
.frameLine {
|
||||
.frameName {
|
||||
flex: none;
|
||||
}
|
||||
.frameName,
|
||||
.frameFile {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.frameFile {
|
||||
flex: 0 1000 auto;
|
||||
min-width: min(12ch, 32%);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
/* ", File.java:12" hugs the name, cancelling the row gap. */
|
||||
margin-left: -6px;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.hiddenFrames {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg-subtle);
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Debug tool window: toolbar, Threads & Variables (frames + variables), Console. */
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { basename, useProject } from "@/platform/project";
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
type TabItem,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { revealVertically } from "@/ui/Tabs";
|
||||
import { setMuted, useBreakpoints } from "../breakpoints/store";
|
||||
import { frameLabel, groupFrames } from "../frames";
|
||||
import { blurDebugView, focusDebugView } from "./focusedView";
|
||||
@@ -348,15 +347,10 @@ function ThreadsAndVariables({ session }: { session: DebugSession }) {
|
||||
function FramesPane({ session }: { session: DebugSession }) {
|
||||
const root = useProject((s) => s.project?.root ?? null);
|
||||
const [showAll, setShowAll] = useState(false);
|
||||
const list = useRef<HTMLDivElement>(null);
|
||||
const selectedRow = useRef<HTMLButtonElement>(null);
|
||||
const items = useMemo(
|
||||
() => groupFrames(session.frames, root, session.selectedFrame, showAll),
|
||||
[session.frames, root, session.selectedFrame, showAll],
|
||||
);
|
||||
useLayoutEffect(() => {
|
||||
if (list.current && selectedRow.current) revealVertically(list.current, selectedRow.current);
|
||||
}, [items]);
|
||||
const paused = session.status === "paused";
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return;
|
||||
@@ -371,24 +365,19 @@ function FramesPane({ session }: { session: DebugSession }) {
|
||||
return (
|
||||
<div className={styles.frames}>
|
||||
{session.threads.length > 0 && (
|
||||
<div className={styles.threadHeader}>
|
||||
<Select
|
||||
value={session.selectedThread != null ? String(session.selectedThread) : null}
|
||||
options={session.threads.map((t) => ({
|
||||
value: String(t.id),
|
||||
label: t.name,
|
||||
verbatim: true,
|
||||
detail: t.id === session.stoppedThread ? "suspended" : undefined,
|
||||
}))}
|
||||
onChange={(v) => void selectThread(session.id, +v)}
|
||||
aria-label="Thread"
|
||||
variant="ghost"
|
||||
className={styles.threadSelect}
|
||||
/>
|
||||
</div>
|
||||
<Select
|
||||
value={session.selectedThread != null ? String(session.selectedThread) : null}
|
||||
options={session.threads.map((t) => ({
|
||||
value: String(t.id),
|
||||
label: t.name,
|
||||
detail: t.id === session.stoppedThread ? "suspended" : undefined,
|
||||
}))}
|
||||
onChange={(v) => void selectThread(session.id, +v)}
|
||||
aria-label="Thread"
|
||||
className={styles.threadSelect}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
ref={list}
|
||||
className={styles.frameList}
|
||||
role="listbox"
|
||||
aria-label={tx("Frames")}
|
||||
@@ -426,11 +415,9 @@ function FramesPane({ session }: { session: DebugSession }) {
|
||||
) : (
|
||||
<button
|
||||
key={item.frame.id}
|
||||
ref={item.frame.id === session.selectedFrame ? selectedRow : undefined}
|
||||
type="button"
|
||||
role="option"
|
||||
aria-selected={item.frame.id === session.selectedFrame}
|
||||
title={item.frame.path ? `${frameLabel(item.frame)}, ${basename(item.frame.path)}` : item.frame.name}
|
||||
className={clsx(
|
||||
styles.frame,
|
||||
item.frame.id === session.selectedFrame && styles.frameSelected,
|
||||
@@ -472,15 +459,13 @@ function FramesPane({ session }: { session: DebugSession }) {
|
||||
}}
|
||||
>
|
||||
<Icon name="method" size={16} className={styles.frameIcon} />
|
||||
<span className={styles.frameText}>
|
||||
<span className={styles.frameLabel}>
|
||||
<span className={styles.frameName}>{item.frame.name}</span>
|
||||
{item.frame.path && item.frame.line >= 0 && (
|
||||
<span className={styles.frameLine}>:{item.frame.line + 1}</span>
|
||||
)}
|
||||
<span className={styles.frameName}>{item.frame.name}</span>
|
||||
{item.frame.path && (
|
||||
<span className={styles.frameFile}>
|
||||
, {basename(item.frame.path)}
|
||||
{item.frame.line >= 0 ? `:${item.frame.line + 1}` : ""}
|
||||
</span>
|
||||
{item.frame.path && <span className={styles.frameFile}>, {basename(item.frame.path)}</span>}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
),
|
||||
)}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { EditorSelection, EditorState } from "@codemirror/state";
|
||||
import type { LineHunk } from "@/bindings";
|
||||
import { applyRollback, hunkAtLine, hunkKeys, hunksOverlapping, nextHunk, prevHunk, rollbackEdit } from "../hunks";
|
||||
@@ -132,38 +132,6 @@ describe("change lane clicks", () => {
|
||||
setHunkPopupHooks(null);
|
||||
parent.remove();
|
||||
});
|
||||
|
||||
it("opens a deletion from the hit area above its line", async () => {
|
||||
const { EditorView } = await import("@codemirror/view");
|
||||
const { changeLane } = await import("@/editor/core/cm/lanes");
|
||||
const { changeMarkers, setHunkPopupHooks } = await import("../gutter");
|
||||
const opened: string[] = [];
|
||||
setHunkPopupHooks({ open: (_v, hunk) => opened.push(hunk.kind), docChanged: () => {} });
|
||||
const parent = document.createElement("div");
|
||||
document.body.appendChild(parent);
|
||||
const view = new EditorView({
|
||||
parent,
|
||||
state: EditorState.create({
|
||||
doc: "a\nc\n",
|
||||
extensions: [changeLane, changeMarkers({ path: "/p/f.txt" } as Parameters<typeof changeMarkers>[0])],
|
||||
}),
|
||||
});
|
||||
view.dispatch({ effects: setHunksEffect.of([h("deleted", 1, 0, 1, 1, "b\n")]) });
|
||||
const lane = view.dom.querySelector<HTMLElement>(".cm-openidea-lane")!;
|
||||
vi.spyOn(lane, "getBoundingClientRect").mockReturnValue({ left: 100, right: 104, top: 0, bottom: 100 } as DOMRect);
|
||||
const marker = view.dom.querySelector<HTMLElement>(".cm-openidea-laneDeleted")!;
|
||||
vi.spyOn(marker, "getBoundingClientRect").mockReturnValue({ left: 96, top: 14, width: 12, height: 12 } as DOMRect);
|
||||
const previous = view.lineBlockAt(view.state.doc.line(1).from);
|
||||
const deleted = view.lineBlockAt(view.state.doc.line(2).from);
|
||||
vi.spyOn(view, "lineBlockAtHeight").mockImplementation((height) => (height < 20 ? previous : deleted));
|
||||
marker.dispatchEvent(
|
||||
new MouseEvent("mousedown", { bubbles: true, cancelable: true, button: 0, clientX: 96, clientY: 17 }),
|
||||
);
|
||||
expect(opened).toEqual(["deleted"]);
|
||||
view.destroy();
|
||||
setHunkPopupHooks(null);
|
||||
parent.remove();
|
||||
});
|
||||
});
|
||||
|
||||
describe("change markers in folds", () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { useEffect, useId, useState } from "react";
|
||||
import type { FileStatus, Stash } from "@/bindings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { Checkbox, Dialog, IconButton, Input, T } from "@/ui";
|
||||
import { Checkbox, Dialog, Icon, IconButton, Input, T, fileIconName } from "@/ui";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { addedThenDeleted, groupOf, remainingOverrides, renamedFromPath } from "./changes";
|
||||
import { runCommitChecks } from "./commitChecks";
|
||||
@@ -12,11 +12,10 @@ import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import { notifyFileOperation } from "@/platform/fileOps";
|
||||
import { confirmDialog, openDialog } from "./dialogs";
|
||||
import { RepoPicker, useBranchInfo } from "./gitMenuDialogs";
|
||||
import { baseName, effectiveKind, stripSlash } from "./model";
|
||||
import { KIND_COLOR, baseName, dirName, effectiveKind, relTo, stripSlash } from "./model";
|
||||
import { logConsole, runOp, saveAll } from "./ops";
|
||||
import { ensureCommitIdentity } from "./commitIdentity";
|
||||
import { showCompareRevisions } from "./operations";
|
||||
import { FileChecklist } from "./shelf";
|
||||
import { currentRepo, loadStashes, refreshNow, useVcs } from "./store";
|
||||
import styles from "./common.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
@@ -217,6 +216,7 @@ export function showRollbackDialog(files: FileStatus[]) {
|
||||
}
|
||||
|
||||
function RollbackDialog({ files, onClose }: { files: FileStatus[]; onClose: () => void }) {
|
||||
const root = useVcs((s) => s.root) ?? "";
|
||||
const [selected, setSelected] = useState(() => new Set(files.map((f) => f.path)));
|
||||
const [deleteAdded, setDeleteAdded] = useState(false);
|
||||
const hasAdded = files.some((f) => f.staged === "added");
|
||||
@@ -256,7 +256,32 @@ function RollbackDialog({ files, onClose }: { files: FileStatus[]; onClose: () =
|
||||
? tx`${selected.size} of ${files.length} file will be reverted to their last committed state. Uncommitted changes are lost.`
|
||||
: tx`${selected.size} of ${files.length} files will be reverted to their last committed state. Uncommitted changes are lost.`}
|
||||
</div>
|
||||
<FileChecklist files={files} selected={selected} onChange={setSelected} label="Files to roll back" />
|
||||
<div className={styles.fileList} role="group" aria-label={tx("Files to roll back")}>
|
||||
{files.map((f) => {
|
||||
const kind = effectiveKind(f) ?? "modified";
|
||||
return (
|
||||
<div key={f.path} className={styles.fileRow}>
|
||||
<Checkbox
|
||||
aria-label={tx`Include ${baseName(f.path)}`}
|
||||
checked={selected.has(f.path)}
|
||||
onChange={(v) =>
|
||||
setSelected((s) => {
|
||||
const n = new Set(s);
|
||||
if (v) n.add(f.path);
|
||||
else n.delete(f.path);
|
||||
return n;
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Icon name={fileIconName(baseName(f.path), f.path)} size={14} />
|
||||
<span className={styles.fileName} style={{ color: KIND_COLOR[kind] }}>
|
||||
{baseName(f.path)}
|
||||
</span>
|
||||
<span className={styles.fileDir}>{dirName(relTo(root, stripSlash(f.path)))}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div style={{ height: 12 }} />
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -235,19 +235,14 @@ const laneTheme = EditorView.baseTheme({
|
||||
*/
|
||||
export function laneMouseDown(view: EditorView, event: MouseEvent, path: string): boolean {
|
||||
if (event.button !== 0 || event.shiftKey || event.metaKey || event.ctrlKey || event.altKey) return false;
|
||||
const deletedMarker = event.target instanceof Element ? event.target.closest(".cm-openidea-laneDeleted") : null;
|
||||
const lane = view.dom.querySelector(".cm-openidea-lane");
|
||||
if (!lane) return false;
|
||||
if (!deletedMarker) {
|
||||
const rect = lane.getBoundingClientRect();
|
||||
if (event.clientX < rect.left - 1 || event.clientX > rect.right + 3) return false;
|
||||
if (event.clientY < rect.top || event.clientY > rect.bottom) return false;
|
||||
}
|
||||
const markerRect = deletedMarker?.getBoundingClientRect();
|
||||
const y = markerRect ? markerRect.top + markerRect.height / 2 + 1 : event.clientY;
|
||||
const block = view.lineBlockAtHeight(y - view.documentTop);
|
||||
const rect = lane.getBoundingClientRect();
|
||||
if (event.clientX < rect.left - 1 || event.clientX > rect.right + 3) return false;
|
||||
if (event.clientY < rect.top || event.clientY > rect.bottom) return false;
|
||||
const block = view.lineBlockAtHeight(event.clientY - view.documentTop);
|
||||
const hunk = hunkAtPos(view.state, block.from);
|
||||
if (!hunk || (deletedMarker && hunk.kind !== "deleted")) return false;
|
||||
if (!hunk) return false;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
showHunkPopup(view, hunk, path);
|
||||
|
||||
Reference in new issue
Заблокувати користувача