дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 18:17:15 +02:00
Порівняти коміти
6
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
fab386a4b4 | ||
|
|
e89b565a78 | ||
|
|
b2a1ee2204 | ||
|
|
828cb271d9 | ||
|
|
ed369c2a6d | ||
|
|
c79530f7ad |
No files matched your search
@@ -18,18 +18,27 @@ test("keeps breakpoint details editable when the dialog gets narrow", async ({ w
|
||||
const list = dialog.getByRole("listbox", { name: "All breakpoints" });
|
||||
const condition = dialog.locator('input[aria-label="Condition"]');
|
||||
await expect(condition).toHaveValue("amount > 100");
|
||||
const actions = dialog.getByRole("group", { name: "Actions", exact: true });
|
||||
await expect(actions).toBeVisible();
|
||||
await expect(dialog.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
await expect(dialog.getByText("Hit count", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
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}");
|
||||
await actions.getByRole("checkbox", { name: '"Breakpoint hit" message', exact: true }).check();
|
||||
await actions.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check();
|
||||
const log = actions.getByRole("textbox", { name: "Evaluate and log", exact: true });
|
||||
await log.fill("total: {amount}");
|
||||
const temporary = actions.getByRole("checkbox", { name: "Remove once hit", exact: true });
|
||||
await temporary.check();
|
||||
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 expect(log).toHaveValue("total: {amount}");
|
||||
await expect(temporary).toBeChecked();
|
||||
|
||||
await page.setViewportSize({ width: 1080, height: 760 });
|
||||
const divider = dialog.locator('[data-separator][aria-orientation="vertical"]');
|
||||
|
||||
@@ -715,6 +715,58 @@ test("rename keeps the typed name, uses the editor font and shows long preview n
|
||||
await expect.poll(() => ipcCalls(page, "apply_workspace_edit")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("intentions separate quick fixes from other actions and navigate across the divider", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const editor = await openSample(page);
|
||||
const fix = "Correct the Order type";
|
||||
const refactor = "Extract the order value";
|
||||
await page.evaluate(
|
||||
({ file, edit, fix, refactor }) => {
|
||||
const action = (title: string, kind: string, newText: string) => ({
|
||||
title,
|
||||
kind,
|
||||
isPreferred: false,
|
||||
disabledReason: null,
|
||||
edit: { files: [{ kind: "edit", path: file, edits: [{ range: edit, new_text: newText }] }] },
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
});
|
||||
window.__ipc.handlers.lsp_code_actions = () => [
|
||||
action(refactor, "refactor.extract", "ExtractedOrder"),
|
||||
action(fix, "quickfix", "CorrectOrder"),
|
||||
];
|
||||
window.__ipc.handlers.lsp_execute_code_action = () => [];
|
||||
},
|
||||
{ file: FILE, edit: range(20, 19, 24), fix, refactor },
|
||||
);
|
||||
await caretAt(editor, page, "val order: Order", "Order ");
|
||||
await page.keyboard.press("Alt+Enter");
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Intentions", exact: true });
|
||||
const list = popup.getByRole("listbox", { name: "Intentions" });
|
||||
const divider = list.locator("[class*=listDivider]");
|
||||
const preview = popup.locator('[aria-label="Preview"] pre');
|
||||
await expect(list.getByRole("option", { name: fix })).toBeVisible();
|
||||
await page.keyboard.type("order");
|
||||
await expect(list.getByRole("option")).toHaveText([fix, refactor]);
|
||||
await expect(divider).toHaveCount(1);
|
||||
await expect(list.getByRole("option", { name: fix })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(preview).toContainText("CorrectOrder");
|
||||
await list.press("ArrowDown");
|
||||
await expect(list.getByRole("option", { name: refactor })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(preview).toContainText("ExtractedOrder");
|
||||
|
||||
for (const _character of "order") await list.press("Backspace");
|
||||
await page.keyboard.type("extract");
|
||||
await expect(list.getByRole("option")).toHaveText([refactor]);
|
||||
await expect(divider).toHaveCount(0);
|
||||
await list.press("Enter");
|
||||
await expect(popup).toBeHidden();
|
||||
await expect.poll(() => ipcCalls(page, "lsp_execute_code_action")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("intention previews fit narrow windows and wrap long code lines", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1600, height: 900 });
|
||||
const editor = await openSample(page);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function openChain(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
@@ -46,6 +46,70 @@ test("a narrow diff keeps navigation, settings and the difference count visible"
|
||||
await expect(toolbar).toContainText("1 of 1 differences");
|
||||
});
|
||||
|
||||
test("revision titles keep both filenames in view when the diff divider moves", async ({ workbench: page }) => {
|
||||
const leftName = "OrderRoutes.ts";
|
||||
const rightName = "OrdersRoutes.ts";
|
||||
const directory = "services/customer-orders/fulfillment/warehouse-routing/primary";
|
||||
await page.setViewportSize({ width: 800, height: 650 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ directory, leftName, rightName }) => {
|
||||
const inputPath = "/src/features/vcs/diffInput.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { openDiff } = await import(inputPath);
|
||||
const { hideAllToolWindows } = await import(layoutPath);
|
||||
const leftPath = `/dev/acme-api/${directory}/${leftName}`;
|
||||
const rightPath = `/dev/acme-api/${directory}/${rightName}`;
|
||||
window.__ipc.handlers.vcs_file_at = (args) =>
|
||||
args.rev === "7b70e02c" ? "export const region = 'east';\r\n" : "export const region = 'west';\n";
|
||||
window.__ipc.handlers.vcs_file_mode = () => "100644";
|
||||
hideAllToolWindows();
|
||||
localStorage.setItem("openidea.vcs.diffOptions", JSON.stringify({ mode: "split", alignChanges: false }));
|
||||
await openDiff({
|
||||
path: rightPath,
|
||||
left: { type: "rev", rev: "7b70e02c", path: leftPath },
|
||||
right: { type: "rev", rev: "a8c5f31d", path: rightPath },
|
||||
});
|
||||
},
|
||||
{ directory, leftName, rightName },
|
||||
);
|
||||
const left = page.getByTitle(/^7b70e02c .*OrderRoutes\.ts$/);
|
||||
const right = page.getByTitle(/^a8c5f31d .*OrdersRoutes\.ts$/);
|
||||
const filenamesFit = async () => {
|
||||
for (const [title, filename] of [
|
||||
[left, leftName],
|
||||
[right, rightName],
|
||||
] as const) {
|
||||
await expect(title).toBeVisible();
|
||||
expect(await title.getAttribute("title")).toContain(`${directory}/${filename}`);
|
||||
const text = title.locator("span").filter({ hasText: filename }).last();
|
||||
expect(
|
||||
await text.evaluate((el, filename) => {
|
||||
const node = el.firstChild!;
|
||||
const range = document.createRange();
|
||||
range.setStart(node, (node.textContent ?? "").length - filename.length);
|
||||
range.setEnd(node, (node.textContent ?? "").length);
|
||||
const bounds = range.getBoundingClientRect();
|
||||
const clip = el.getBoundingClientRect();
|
||||
return bounds.left >= clip.left - 1 && bounds.right <= clip.right + 1;
|
||||
}, filename),
|
||||
`${filename} is visible within its revision label`,
|
||||
).toBe(true);
|
||||
}
|
||||
};
|
||||
await filenamesFit();
|
||||
|
||||
const divider = page.getByRole("separator", { name: "Resize diff panes" });
|
||||
const { x, y, width, height } = (await divider.boundingBox())!;
|
||||
const leftWidth = (await left.boundingBox())!.width;
|
||||
await page.mouse.move(x + width / 2, y + height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + width / 2 - 96, y + height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await left.boundingBox())!.width).toBeLessThan(leftWidth - 60);
|
||||
await filenamesFit();
|
||||
});
|
||||
|
||||
test("a medium-width diff keeps its full status beside the viewer tools", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 490, height: 650 });
|
||||
await page.evaluate(async () => {
|
||||
|
||||
@@ -122,6 +122,45 @@ test("a long Run tab fits its side panel with room for the pin and close buttons
|
||||
await expect(run).toBeHidden();
|
||||
});
|
||||
|
||||
test("the Run toolbar keeps primary actions in one row in a side dock", async ({ workbench: page }) => {
|
||||
const output = "Waiting for orders. ".repeat(8).trim();
|
||||
await stubRun(page, [{ kind: "stdout", text: `${output}\n` }], null);
|
||||
const dock = async (width: number) => {
|
||||
await page.evaluate(async (width) => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ path);
|
||||
moveToolWindow("run", "right");
|
||||
setToolWindowSize("right", width);
|
||||
}, width);
|
||||
};
|
||||
await dock(200);
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
const toolbar = run.getByRole("toolbar", { name: "Run actions" });
|
||||
const console = run.getByRole("log");
|
||||
await expect(console).toContainText(output);
|
||||
await expect
|
||||
.poll(() => toolbar.evaluate((el) => new Set([...el.querySelectorAll("button")].map((b) => b.offsetTop)).size))
|
||||
.toBe(1);
|
||||
const more = toolbar.getByRole("button", { name: "More Actions" });
|
||||
const menu = page.getByRole("menu", { name: "More Actions" });
|
||||
await more.press("Enter");
|
||||
const wrap = menu.getByRole("menuitemcheckbox", { name: "Soft-Wrap" });
|
||||
await expect(wrap).toHaveAttribute("aria-checked", "false");
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: "Scroll to End" })).toHaveAttribute("aria-checked", "true");
|
||||
await wrap.click();
|
||||
await expect(menu).toBeHidden();
|
||||
await expect.poll(() => console.evaluate((el) => el.scrollWidth <= el.clientWidth + 1)).toBe(true);
|
||||
|
||||
await dock(340);
|
||||
await expect(toolbar.getByRole("button", { name: "Soft-Wrap" })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(toolbar.getByRole("button", { name: "Scroll to End" })).toBeVisible();
|
||||
await more.click();
|
||||
await expect(menu.getByRole("menuitemcheckbox")).toHaveCount(0);
|
||||
await menu.getByRole("menuitem", { name: "Edit Configurations…" }).click();
|
||||
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a short Run pane has room for the full toolbar above the output", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 400, height: 500 });
|
||||
const output = "Watching for changes…";
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const LONG_RESULT_PATH = "config/RegionalOrderReconciliationEndpointsForSandboxEnvironments.txt";
|
||||
|
||||
async function run(page: Page, id: string) {
|
||||
await page.evaluate(async (id) => {
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
@@ -15,15 +17,16 @@ async function run(page: Page, id: string) {
|
||||
|
||||
async function stubFindMatches(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(() => {
|
||||
await page.evaluate((longPath) => {
|
||||
window.__ipc.handlers.search_validate = () => null;
|
||||
window.__ipc.handlers.search_start = (args) => {
|
||||
const send = (event: unknown) => window.__ipc.send(args.onEvent, event);
|
||||
const text = "base=http://localhost:8080";
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const relPath = `config/endpoint-${i}.txt`;
|
||||
const matches = [{ line: 0, text, ranges: [[5, text.length]], textOffset: 0 }];
|
||||
const relPath = i === 0 ? longPath : `config/endpoint-${i}.txt`;
|
||||
const lines = i === 0 ? [12344, 12345] : [0];
|
||||
const matches = lines.map((line) => ({ line, text, ranges: [[5, text.length]], textOffset: 0 }));
|
||||
send({
|
||||
type: "file",
|
||||
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
|
||||
@@ -31,12 +34,12 @@ async function stubFindMatches(page: Page) {
|
||||
}
|
||||
send({
|
||||
type: "done",
|
||||
summary: { files: 12, matches: 12, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
summary: { files: 12, matches: 13, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
});
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
});
|
||||
}, LONG_RESULT_PATH);
|
||||
}
|
||||
|
||||
async function expectControlsFit(page: Page) {
|
||||
@@ -74,7 +77,8 @@ test.describe("search popups at the minimum window width", () => {
|
||||
await expect(page.getByRole("dialog").locator("header [aria-live]")).toContainText(/match/);
|
||||
const dialog = page.getByRole("dialog");
|
||||
const title = dialog.getByText(id === "find.inPath" ? "Find in Files" : "Replace in Files", { exact: true });
|
||||
const count = dialog.getByText("12 matches in 12 files", { exact: true });
|
||||
const count = dialog.getByText("13 matches in 12 files", { exact: true });
|
||||
const line = dialog.getByText("12345", { exact: true });
|
||||
for (const [width, height] of [
|
||||
[400, 500],
|
||||
[600, 700],
|
||||
@@ -87,6 +91,14 @@ test.describe("search popups at the minimum window width", () => {
|
||||
expect(
|
||||
await text.evaluate((el) => el.getClientRects().length === 1 && el.scrollWidth <= el.clientWidth),
|
||||
).toBe(true);
|
||||
await expect(line).toBeVisible();
|
||||
expect(
|
||||
await line.evaluate(
|
||||
(el) => el.getBoundingClientRect().right <= el.parentElement!.getBoundingClientRect().right + 0.5,
|
||||
),
|
||||
"the line number fits even when the long filename is elided",
|
||||
).toBe(true);
|
||||
await expect(line.locator("..").getByTitle(LONG_RESULT_PATH)).toBeVisible();
|
||||
for (const name of ["Search Context", "Pin Window"])
|
||||
await dialog.getByRole("button", { name, exact: true }).click({ trial: true });
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ vi.mock("@/workbench/contributions", async (orig) => {
|
||||
});
|
||||
|
||||
const { LspPopups, DocumentationWindow } = await import("./Popups");
|
||||
const { closePopup, openPopup, useLspPopup } = await import("./popupStore");
|
||||
const { closePopup, openPopup, updatePopup, useLspPopup } = await import("./popupStore");
|
||||
const { useDocWindow, hoverDoc, pushHistory, stepHistory, hoverCandidates } = await import("./docs");
|
||||
const { mountHoverDoc } = await import("./DocView");
|
||||
const { hoverSource } = await import("./hover");
|
||||
@@ -139,6 +139,31 @@ describe("list popup", () => {
|
||||
expect(onClose).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("keeps the chosen intention when a quick-fix section arrives ahead of it", () => {
|
||||
const local = ["Extract variable", "Inline value"].map((label) => ({
|
||||
id: label,
|
||||
label,
|
||||
section: { id: "intentions" },
|
||||
run: vi.fn(),
|
||||
}));
|
||||
openPopup({ kind: "list", title: "Intentions", anchor: { x: 0, y: 0 }, items: local, busy: true });
|
||||
render(<LspPopups />);
|
||||
fireEvent.keyDown(screen.getByRole("listbox"), { key: "ArrowDown" });
|
||||
expect(screen.getByRole("option", { name: "Inline value", selected: true })).toBeVisible();
|
||||
|
||||
const runFix = vi.fn();
|
||||
act(() =>
|
||||
updatePopup("list", {
|
||||
busy: false,
|
||||
items: [{ id: "fix", label: "Correct type", section: { id: "quick-fixes" }, run: runFix }, ...local],
|
||||
}),
|
||||
);
|
||||
expect(screen.getByRole("option", { name: "Inline value", selected: true })).toBeVisible();
|
||||
fireEvent.keyDown(screen.getByRole("listbox"), { key: "Enter" });
|
||||
expect(local[1]!.run).toHaveBeenCalledOnce();
|
||||
expect(runFix).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("focuses the rows, not the header's pin button, when it opens", () => {
|
||||
openPopup({
|
||||
kind: "list",
|
||||
|
||||
@@ -112,14 +112,10 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
|
||||
const [query, setQuery] = useState("");
|
||||
const rows = useMemo(() => listPopupRows(popup.items, query), [popup.items, query]);
|
||||
const firstEnabled = rows.findIndex((row) => row.kind === "action" && !row.item.disabled);
|
||||
const [active, setActive] = useState(firstEnabled);
|
||||
const clamped = Math.min(active, rows.length - 1);
|
||||
const [activeId, setActiveId] = useState<string | null>(null);
|
||||
const selected = rows.findIndex((row) => row.kind === "action" && row.item.id === activeId);
|
||||
const activeIndex =
|
||||
rows[clamped]?.kind === "action"
|
||||
? clamped
|
||||
: firstEnabled >= 0
|
||||
? firstEnabled
|
||||
: firstSelectable(rows, isListSection);
|
||||
selected >= 0 ? selected : firstEnabled >= 0 ? firstEnabled : firstSelectable(rows, isListSection);
|
||||
const activeRow = rows[activeIndex];
|
||||
const activeItem = activeRow?.kind === "action" ? activeRow.item : undefined;
|
||||
const showIcons = !popup.compact || popup.items.some((item) => item.icon || item.symbol);
|
||||
@@ -183,11 +179,11 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
|
||||
if (item) activate(item);
|
||||
} else if (e.key === "Backspace" && query) {
|
||||
setQuery(query.slice(0, -1));
|
||||
setActive(-1);
|
||||
setActiveId(null);
|
||||
e.preventDefault();
|
||||
} else if (e.key.length === 1 && !(e.key === " " && !query)) {
|
||||
setQuery(query + e.key);
|
||||
setActive(-1);
|
||||
setActiveId(null);
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
@@ -297,7 +293,10 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
|
||||
row.kind === "section" && row.label ? <T>{row.label}</T> : <span className={styles.listDivider} />
|
||||
}
|
||||
activeIndex={activeIndex}
|
||||
onActiveChange={setActive}
|
||||
onActiveChange={(index) => {
|
||||
const row = rows[index];
|
||||
setActiveId(row?.kind === "action" ? row.item.id : null);
|
||||
}}
|
||||
hoverSelects
|
||||
autoFocus
|
||||
aria-label={popup.title}
|
||||
|
||||
@@ -60,11 +60,18 @@ export function quickFixIcon(view: EditorView): "bulb" | "bulb-fix" {
|
||||
|
||||
const isFixItem = (item: ListPopupItem) => item.quickFix ?? item.icon === "bulb-fix";
|
||||
|
||||
/** Local and language-server fixes share icons and the same stable ordering. */
|
||||
/** Local and language-server fixes share icons and are grouped separately from other actions. */
|
||||
export function listedIntentions(view: EditorView, items: ListPopupItem[]): ListPopupItem[] {
|
||||
const rank = (item: ListPopupItem) => (item.disabled ? 4 : 0) + (isFixItem(item) ? 0 : 2) + (item.emphasis ? 0 : 1);
|
||||
return items
|
||||
.map((item) => (isFixItem(item) ? { ...item, quickFix: true, icon: quickFixIcon(view) } : item))
|
||||
.map((item) => {
|
||||
const fix = isFixItem(item);
|
||||
return {
|
||||
...item,
|
||||
...(fix && { quickFix: true, icon: quickFixIcon(view) }),
|
||||
section: item.section ?? { id: item.disabled ? "unavailable" : fix ? "quick-fixes" : "intentions" },
|
||||
};
|
||||
})
|
||||
.sort((a, b) => rank(a) - rank(b));
|
||||
}
|
||||
|
||||
@@ -497,6 +504,7 @@ export function withInspectionControls(view: EditorView, items: ListPopupItem[])
|
||||
...inspections.map((inspection) => ({
|
||||
id: `inspection:${inspection.id}`,
|
||||
label: tx`Inspection '${txPart(inspection.name)}' options`,
|
||||
section: { id: "inspection-options" },
|
||||
icon: "settings",
|
||||
run: () => editInspectionSettings(inspection.id),
|
||||
submenu: intentionControls(inspection),
|
||||
|
||||
@@ -29,6 +29,23 @@
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.bpActions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
}
|
||||
|
||||
.bpActions > legend {
|
||||
padding-inline: var(--space-1);
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.bpTitle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -212,7 +229,7 @@
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.detail .label {
|
||||
:is(.detail, .bpEditor) .label {
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
|
||||
@@ -212,12 +212,14 @@ function BreakpointFields({
|
||||
focus,
|
||||
onEnter,
|
||||
commitRef,
|
||||
showRemoveOnceHit = false,
|
||||
}: {
|
||||
path: string;
|
||||
bp: BreakpointEntry;
|
||||
focus?: "condition" | "log";
|
||||
onEnter?: () => void;
|
||||
commitRef?: MutableRefObject<(() => void) | null>;
|
||||
showRemoveOnceHit?: boolean;
|
||||
}) {
|
||||
const [condition, setCondition] = useState(bp.condition ?? "");
|
||||
const [hitCondition, setHitCondition] = useState(bp.hitCondition ?? "");
|
||||
@@ -308,32 +310,44 @@ function BreakpointFields({
|
||||
aria-label="Hit count condition"
|
||||
/>
|
||||
</label>
|
||||
<Checkbox
|
||||
checked={!!bp.logHit}
|
||||
onChange={(on) => updateBreakpoint(path, bp.id, { logHit: on || undefined })}
|
||||
label={'"Breakpoint hit" message'}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={logEval}
|
||||
onChange={(on) => {
|
||||
setLogEval(on);
|
||||
draft.current = { ...draft.current, logEval: on };
|
||||
commitText();
|
||||
}}
|
||||
label="Evaluate and log"
|
||||
/>
|
||||
{logEval && (
|
||||
<Input
|
||||
mono
|
||||
value={logMessage}
|
||||
onChange={(e) => setLogMessage(e.target.value)}
|
||||
onBlur={commitText}
|
||||
onKeyDown={onKey}
|
||||
placeholder="Value: {expression}"
|
||||
data-autofocus={focus === "log" ? "" : undefined}
|
||||
aria-label="Evaluate and log"
|
||||
<fieldset className={styles.bpActions}>
|
||||
<legend>
|
||||
<T>Actions</T>
|
||||
</legend>
|
||||
<Checkbox
|
||||
checked={!!bp.logHit}
|
||||
onChange={(on) => updateBreakpoint(path, bp.id, { logHit: on || undefined })}
|
||||
label={'"Breakpoint hit" message'}
|
||||
/>
|
||||
)}
|
||||
<Checkbox
|
||||
checked={logEval}
|
||||
onChange={(on) => {
|
||||
setLogEval(on);
|
||||
draft.current = { ...draft.current, logEval: on };
|
||||
commitText();
|
||||
}}
|
||||
label="Evaluate and log"
|
||||
/>
|
||||
{logEval && (
|
||||
<Input
|
||||
mono
|
||||
value={logMessage}
|
||||
onChange={(e) => setLogMessage(e.target.value)}
|
||||
onBlur={commitText}
|
||||
onKeyDown={onKey}
|
||||
placeholder="Value: {expression}"
|
||||
data-autofocus={focus === "log" ? "" : undefined}
|
||||
aria-label="Evaluate and log"
|
||||
/>
|
||||
)}
|
||||
{showRemoveOnceHit && (
|
||||
<Checkbox
|
||||
checked={!!bp.temporary}
|
||||
onChange={(temporary) => updateBreakpoint(path, bp.id, { temporary })}
|
||||
label="Remove once hit"
|
||||
/>
|
||||
)}
|
||||
</fieldset>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -771,12 +785,7 @@ function BreakpointDetail({
|
||||
</Button>
|
||||
</div>
|
||||
{st && <div className={styles.statusLine}>{st.verified ? tx("Verified") : (st.message ?? "Not verified")}</div>}
|
||||
<BreakpointFields path={path} bp={bp} commitRef={commitRef} />
|
||||
<Checkbox
|
||||
checked={!!bp.temporary}
|
||||
onChange={(temporary) => updateBreakpoint(path, bp.id, { temporary })}
|
||||
label="Remove once hit"
|
||||
/>
|
||||
<BreakpointFields path={path} bp={bp} commitRef={commitRef} showRemoveOnceHit />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
type MenuItem,
|
||||
SplitGroup,
|
||||
SplitHandle,
|
||||
SplitPanel,
|
||||
@@ -100,21 +101,33 @@ export function SessionPanel({
|
||||
const [selectedTest, setSelectedTest] = useState<string | null>(null);
|
||||
const [findOpen, setFindOpen] = useState(false);
|
||||
const body = useRef<HTMLDivElement>(null);
|
||||
const moreButton = useRef<HTMLButtonElement>(null);
|
||||
const [moreOpen, setMoreOpen] = useState(false);
|
||||
const [compactToolbar, setCompactToolbar] = useState(false);
|
||||
const [stackedTests, setStackedTests] = useState(false);
|
||||
const testSplit = useRef<GroupImperativeHandle>(null);
|
||||
const testLayouts = useRef<Record<keyof typeof TEST_SPLIT_DEFAULTS, Layout>>({ ...TEST_SPLIT_DEFAULTS });
|
||||
const testOrientation = stackedTests ? "vertical" : "horizontal";
|
||||
const hasRuntime = !!rt;
|
||||
const hasTests = !!rt?.tests;
|
||||
const canUpdateApplication = isUpdatable(session.config);
|
||||
const hasFlutterActions = supportsHotReload(session.config);
|
||||
// Eight standard buttons with group spacing and insets, then 24 px plus gap per extra button.
|
||||
const fullToolbarWidth = 228 + 26 * (Number(hasTests) + Number(canUpdateApplication) + 2 * Number(hasFlutterActions));
|
||||
useLayoutEffect(() => {
|
||||
const pane = body.current;
|
||||
if (!hasTests || !pane) return;
|
||||
const measure = () => setStackedTests(pane.clientWidth < 560);
|
||||
if (!hasRuntime || !pane || (!showLifecycle && !hasTests)) return;
|
||||
const measure = () => {
|
||||
const width = pane.clientWidth;
|
||||
if (showLifecycle) setCompactToolbar(width < fullToolbarWidth);
|
||||
if (hasTests) setStackedTests(width < 560);
|
||||
};
|
||||
measure();
|
||||
if (typeof ResizeObserver === "undefined") return;
|
||||
const resize = new ResizeObserver(measure);
|
||||
resize.observe(pane);
|
||||
return () => resize.disconnect();
|
||||
}, [hasTests]);
|
||||
}, [hasRuntime, hasTests, showLifecycle, fullToolbarWidth]);
|
||||
useLayoutEffect(() => {
|
||||
if (hasTests) testSplit.current?.setLayout(testLayouts.current[testOrientation]);
|
||||
}, [hasTests, testOrientation]);
|
||||
@@ -157,7 +170,24 @@ export function SessionPanel({
|
||||
}, [selectedTest, rt, version]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (!rt) return null;
|
||||
const toggleWrap = () => setWrapOverride(!softWrap);
|
||||
const overflowConsoleToggles = showLifecycle && compactToolbar && !rt.terminal;
|
||||
const consoleToggles = [
|
||||
{ label: "Scroll to End", icon: "scroll-to-end", checked: follow, run: () => setFollow((v) => !v) },
|
||||
{ label: "Soft-Wrap", icon: "soft-wrap", checked: softWrap, run: () => setWrapOverride(!softWrap) },
|
||||
];
|
||||
const moreItems: MenuItem[] = [{ kind: "action", action: "run.editConfigs", arg: session.config.id }];
|
||||
if (overflowConsoleToggles) {
|
||||
moreItems.unshift(...consoleToggles, { kind: "separator" });
|
||||
}
|
||||
const stopButton = (
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title={session.status === "stopping" ? tx`Stopping… (click to kill)` : "Stop"}
|
||||
tone={running ? "danger" : "default"}
|
||||
disabled={!running}
|
||||
onClick={() => void stopSession(session.id)}
|
||||
/>
|
||||
);
|
||||
|
||||
const consoleColumn = (
|
||||
<div className={styles.consoleColumn}>
|
||||
@@ -223,6 +253,7 @@ export function SessionPanel({
|
||||
shortcut={shortcutLabel("run.rerun")}
|
||||
onClick={() => rerunSession(session.id)}
|
||||
/>
|
||||
{!hasFlutterActions && stopButton}
|
||||
{/* Switch the launch mode: the same configuration started under the debugger. */}
|
||||
<IconButton
|
||||
icon="debug"
|
||||
@@ -240,14 +271,7 @@ export function SessionPanel({
|
||||
onClick={() => void rerunFailed(session.id)}
|
||||
/>
|
||||
)}
|
||||
<IconButton
|
||||
icon="stop"
|
||||
title={session.status === "stopping" ? tx`Stopping… (click to kill)` : "Stop"}
|
||||
tone={running ? "danger" : "default"}
|
||||
disabled={!running}
|
||||
onClick={() => void stopSession(session.id)}
|
||||
/>
|
||||
{isUpdatable(session.config) && (
|
||||
{canUpdateApplication && (
|
||||
<IconButton
|
||||
icon="refresh"
|
||||
title="Update Application"
|
||||
@@ -256,8 +280,9 @@ export function SessionPanel({
|
||||
onClick={() => showApplicationUpdate(session.id)}
|
||||
/>
|
||||
)}
|
||||
{supportsHotReload(session.config) && (
|
||||
{hasFlutterActions && (
|
||||
<>
|
||||
{stopButton}
|
||||
<IconButton
|
||||
icon="hot-reload"
|
||||
title="Hot Reload"
|
||||
@@ -286,23 +311,41 @@ export function SessionPanel({
|
||||
pressed={findOpen}
|
||||
onClick={() => setFindOpen((v) => !v)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="scroll-to-end"
|
||||
title="Scroll to End"
|
||||
pressed={follow}
|
||||
onClick={() => setFollow((v) => !v)}
|
||||
/>
|
||||
<IconButton icon="soft-wrap" title="Soft-Wrap" pressed={softWrap} onClick={toggleWrap} />
|
||||
{!overflowConsoleToggles &&
|
||||
consoleToggles.map(({ label, icon, checked, run }) => (
|
||||
<IconButton key={label} icon={icon} title={label} pressed={checked} onClick={run} />
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
<IconButton icon="trash" title="Clear All" onClick={() => clearConsole(session.id)} />
|
||||
</div>
|
||||
<div className={styles.toolbarGroup}>
|
||||
<IconButton
|
||||
icon="settings"
|
||||
title="Edit Configurations…"
|
||||
onClick={() => void executeAction("run.editConfigs", session.config.id)}
|
||||
/>
|
||||
{showLifecycle ? (
|
||||
<>
|
||||
<IconButton
|
||||
ref={moreButton}
|
||||
icon="more-horizontal"
|
||||
title="More Actions"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={moreOpen}
|
||||
onClick={() => setMoreOpen((open) => !open)}
|
||||
/>
|
||||
<Menu
|
||||
open={moreOpen}
|
||||
anchor={moreButton}
|
||||
aria-label="More Actions"
|
||||
placement="bottom-end"
|
||||
items={moreItems}
|
||||
onClose={() => setMoreOpen(false)}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<IconButton
|
||||
icon="settings"
|
||||
title="Edit Configurations…"
|
||||
onClick={() => void executeAction("run.editConfigs", session.config.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div ref={body} className={styles.sessionBody}>
|
||||
|
||||
@@ -162,8 +162,8 @@
|
||||
}
|
||||
.outdated .rowText,
|
||||
.outdated .rowText *,
|
||||
.outdated .rowFile,
|
||||
.outdated .rowFile * {
|
||||
.outdated .rowLocation,
|
||||
.outdated .rowLocation * {
|
||||
color: var(--fg-faint);
|
||||
}
|
||||
.rowText {
|
||||
@@ -174,18 +174,28 @@
|
||||
font-family: var(--font-mono);
|
||||
font-weight: var(--fw-code);
|
||||
}
|
||||
.rowFile {
|
||||
.rowLocation {
|
||||
flex: none;
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1-5);
|
||||
max-width: 40%;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.rowLocationActive {
|
||||
color: var(--fg-emphasis);
|
||||
}
|
||||
.rowFile {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.rowFileActive {
|
||||
.rowFileRepeated {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.rowLine {
|
||||
color: var(--fg-faint);
|
||||
flex: none;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.previewHeader {
|
||||
|
||||
@@ -611,6 +611,7 @@ function FindInFilesDialog() {
|
||||
}
|
||||
renderItem={(r, st) => {
|
||||
const state = s.replace ? groupState(r, marks) : "pending";
|
||||
const repeatedFile = !st.active && rows[st.index - 1]?.path === r.path;
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
@@ -626,13 +627,20 @@ function FindInFilesDialog() {
|
||||
source={{ path: r.path, line: r.line, col: r.textCol }}
|
||||
/>
|
||||
</span>
|
||||
<span className={clsx(styles.rowFile, st.active && styles.rowFileActive)}>
|
||||
{state === "done" && (
|
||||
<span className={styles.rowLine}>
|
||||
<T>replaced ·</T>{" "}
|
||||
</span>
|
||||
)}
|
||||
{workspace ? r.relPath : basename(r.relPath)} <span className={styles.rowLine}>{r.line + 1}</span>
|
||||
<span className={clsx(styles.rowLocation, st.active && styles.rowLocationActive)}>
|
||||
<span
|
||||
className={clsx(styles.rowFile, repeatedFile && styles.rowFileRepeated)}
|
||||
title={r.relPath}
|
||||
dir="auto"
|
||||
>
|
||||
{state === "done" && (
|
||||
<>
|
||||
<T>replaced ·</T>{" "}
|
||||
</>
|
||||
)}
|
||||
{workspace ? r.relPath : basename(r.relPath)}
|
||||
</span>{" "}
|
||||
<span className={styles.rowLine}>{r.line + 1}</span>
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -118,6 +118,22 @@
|
||||
.sourceLabels .labelFile {
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.labelFile.revisionPath {
|
||||
display: inline-flex;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.revisionDirectory,
|
||||
.revisionFilename {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.revisionFilename {
|
||||
/* Let the directory shrink first, then elide the filename if it still exceeds the path's width. */
|
||||
flex: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
.badge {
|
||||
padding: 0 5px;
|
||||
border-radius: var(--radius-small);
|
||||
|
||||
@@ -111,6 +111,23 @@ import styles from "./DiffEditor.module.css";
|
||||
/** Commands of the focused diff viewer (diff.* actions, vcs.nextChange / prevChange). */
|
||||
export { focusedDiffNavigator, type DiffNavigator };
|
||||
|
||||
interface PaneTitle {
|
||||
label: string;
|
||||
detail?: string;
|
||||
revisionPath?: string;
|
||||
}
|
||||
|
||||
function PaneTitleDetail({ detail, revisionPath }: PaneTitle) {
|
||||
if (!revisionPath) return detail ? <span className={styles.labelFile}>{detail}</span> : null;
|
||||
const filenameStart = revisionPath.lastIndexOf("/") + 1;
|
||||
return (
|
||||
<span className={clsx(styles.labelFile, styles.revisionPath)}>
|
||||
{filenameStart > 0 && <span className={styles.revisionDirectory}>{revisionPath.slice(0, filenameStart)}</span>}
|
||||
<span className={styles.revisionFilename}>{revisionPath.slice(filenameStart)}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface Views {
|
||||
/** The right / unified editor (chunks live here). */
|
||||
b: EditorView;
|
||||
@@ -1371,7 +1388,7 @@ export function DiffEditor({
|
||||
const canStage = editableB && isWorktree(right) && left.type === "rev" && !!useVcs.getState().root;
|
||||
const hasSource = !!source;
|
||||
|
||||
const paneTitle = (s: DiffSide): { label: string; detail?: string } => {
|
||||
const paneTitle = (s: DiffSide): PaneTitle => {
|
||||
if (s.type === "worktree" || s.type === "text") return { label: sideLabel(s), detail: s.labelDetail };
|
||||
if (s.type !== "rev") return { label: sideLabel(s) };
|
||||
const file = s.path ?? path;
|
||||
@@ -1379,13 +1396,13 @@ export function DiffEditor({
|
||||
const commit = !s.label && s.rev === "HEAD" && root ? heads[root]?.headCommit : null;
|
||||
return {
|
||||
label: commit ? commit.slice(0, 8) : sideLabel(s),
|
||||
detail: root && file.startsWith(`${root}/`) ? file.slice(root.length + 1) : file,
|
||||
revisionPath: root && file.startsWith(`${root}/`) ? file.slice(root.length + 1) : file,
|
||||
};
|
||||
};
|
||||
const titleA = paneTitle(left);
|
||||
const titleB = paneTitle(right);
|
||||
const captionA = [titleA.label, titleA.detail].filter(Boolean).join(" ");
|
||||
const captionB = [titleB.label, titleB.detail].filter(Boolean).join(" ");
|
||||
const captionA = [titleA.label, titleA.revisionPath ?? titleA.detail].filter(Boolean).join(" ");
|
||||
const captionB = [titleB.label, titleB.revisionPath ?? titleB.detail].filter(Boolean).join(" ");
|
||||
const sourceLabels = "labelDetail" in left || "labelDetail" in right;
|
||||
const labels = clsx(styles.labels, sourceLabels && styles.sourceLabels);
|
||||
|
||||
@@ -1591,7 +1608,7 @@ export function DiffEditor({
|
||||
<div className={labels}>
|
||||
<span className={styles.label} title={captionA}>
|
||||
<span className={styles.labelText}>{titleA.label}</span>
|
||||
{titleA.detail && <span className={styles.labelFile}>{titleA.detail}</span>}
|
||||
<PaneTitleDetail {...titleA} />
|
||||
{eolDiffers && eolA && <span className={styles.badge}>{badgeA}</span>}
|
||||
{editableA && (
|
||||
<span className={styles.badge}>
|
||||
@@ -1601,7 +1618,7 @@ export function DiffEditor({
|
||||
</span>
|
||||
<span className={styles.label} title={captionB}>
|
||||
<span className={styles.labelText}>{titleB.label}</span>
|
||||
{titleB.detail && <span className={styles.labelFile}>{titleB.detail}</span>}
|
||||
<PaneTitleDetail {...titleB} />
|
||||
{eolDiffers && eolB && <span className={styles.badge}>{badgeB}</span>}
|
||||
{editableB && (
|
||||
<span className={styles.badge}>{left.type === "rev" ? tx("working copy") : tx("editable")}</span>
|
||||
@@ -1612,10 +1629,10 @@ export function DiffEditor({
|
||||
<div className={labels}>
|
||||
<span className={styles.label} title={sourceLabels ? `${captionA} → ${captionB}` : undefined}>
|
||||
<span className={styles.labelText}>{sideLabel(left)}</span>
|
||||
{sourceLabels && titleA.detail && <span className={styles.labelFile}>{titleA.detail}</span>}
|
||||
{sourceLabels && <PaneTitleDetail {...titleA} />}
|
||||
{eolDiffers && eolA && <span className={styles.badge}>{badgeA}</span>} →
|
||||
<span className={styles.labelText}>{sideLabel(right)}</span>
|
||||
{sourceLabels && titleB.detail && <span className={styles.labelFile}>{titleB.detail}</span>}
|
||||
{sourceLabels && <PaneTitleDetail {...titleB} />}
|
||||
{eolDiffers && eolB && <span className={styles.badge}>{badgeB}</span>}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Заблокувати користувача