mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 09:39:27 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98856fd5a1 | ||
|
|
d3be99543d | ||
|
|
f0cc99a4c7 | ||
|
|
8db16dea32 | ||
|
|
6a7297519c | ||
|
|
08362db3ca | ||
|
|
b7f3df0472 | ||
|
|
c5824771c1 | ||
|
|
40e5f9b7b3 | ||
|
|
8bc82d08c6 | ||
|
|
b0473f17b5 | ||
|
|
21264641ba | ||
|
|
3ce4578600 | ||
|
|
e89b565a78 | ||
|
|
b2a1ee2204 | ||
|
|
828cb271d9 | ||
|
|
ed369c2a6d | ||
|
|
3103ec19f9 | ||
|
|
026ef8794f | ||
|
|
ca05825d7c |
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);
|
||||
|
||||
@@ -200,86 +200,3 @@ test("Evaluate keeps a multiline expression and its result visible in a short di
|
||||
await expect(field).toHaveValue(expression);
|
||||
await expect(field).toBeFocused();
|
||||
});
|
||||
|
||||
test("Variables keeps evaluation, watches and expression history together in a narrow dock", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 720, height: 620 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (session) => {
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.debug_capabilities = () => ({});
|
||||
handlers.debug_completions = () => [];
|
||||
handlers.debug_scopes = () => [];
|
||||
handlers.debug_evaluate_in = () => ({
|
||||
name: "result",
|
||||
value: "42",
|
||||
typeName: "int",
|
||||
variablesReference: 0,
|
||||
evaluateName: null,
|
||||
});
|
||||
const statePath = "/src/features/debugger/state.ts";
|
||||
const historyPath = "/src/features/debugger/ui/expressionHistory.ts";
|
||||
const projectPath = "/src/platform/project.ts";
|
||||
const servicesPath = "/src/workbench/contributions.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ statePath);
|
||||
const { pushHistory } = await import(/* @vite-ignore */ historyPath);
|
||||
const { useProject } = await import(/* @vite-ignore */ projectPath);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ servicesPath);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutPath);
|
||||
const settings = useProject.getState().settings;
|
||||
useProject.setState({
|
||||
settings: { ...settings, editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18 } },
|
||||
});
|
||||
pushHistory("evaluate", "order.total + tax");
|
||||
pushHistory("evaluate", "if ready:\n settle()");
|
||||
adoptSession(session, { name: "Checkout", adapter: "debugpy", status: "paused", selectedFrame: 11 });
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 285);
|
||||
toolWindowService().show("debug", true);
|
||||
}, SESSION);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const variables = debug.getByRole("tab", { name: "Variables", exact: true });
|
||||
if (await variables.isVisible()) await variables.click();
|
||||
const field = debug.getByRole("textbox", { name: "Evaluate expression", exact: true });
|
||||
const historyButton = debug.getByRole("button", { name: "History", exact: true });
|
||||
const watch = debug.getByRole("button", { name: "Add to Watches", exact: true });
|
||||
await expect(field).toBeVisible();
|
||||
await expect(historyButton).toBeVisible();
|
||||
await expect(field).toHaveAttribute("placeholder", "Evaluate expression");
|
||||
await expect(field).toHaveCSS("font-family", /^"?Consolas"?,/);
|
||||
await expect(field).toHaveCSS("font-size", "13px");
|
||||
expect((await field.boundingBox())!.width).toBeGreaterThan(100);
|
||||
expect((await watch.boundingBox())!.x).toBeLessThan((await historyButton.boundingBox())!.x);
|
||||
|
||||
await historyButton.click();
|
||||
const menu = page.getByRole("menu", { name: "Expression history", exact: true });
|
||||
await expect(menu.getByRole("menuitem")).toHaveText(["order.total + tax"]);
|
||||
const row = (await field.locator("..").boundingBox())!;
|
||||
const popup = (await menu.locator("..").boundingBox())!;
|
||||
expect(popup.x).toBeCloseTo(row.x, 0);
|
||||
expect(popup.width).toBeCloseTo(row.width, 0);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(historyButton).toBeFocused();
|
||||
|
||||
await historyButton.press("Enter");
|
||||
await menu.getByRole("menuitem", { name: "order.total + tax" }).press("Enter");
|
||||
await expect(field).toBeFocused();
|
||||
await expect(field).toHaveValue("order.total + tax");
|
||||
await field.press("Enter");
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "debug_evaluate_in"))
|
||||
.toContainEqual(expect.objectContaining({ expression: "order.total + tax", context: "repl" }));
|
||||
|
||||
await field.fill("order.total");
|
||||
await watch.click();
|
||||
await expect(field).toHaveValue("");
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "debug_evaluate_in"))
|
||||
.toContainEqual(expect.objectContaining({ expression: "order.total", context: "watch" }));
|
||||
await historyButton.click();
|
||||
await expect(menu.getByRole("menuitem")).toHaveText(["order.total", "order.total + tax"]);
|
||||
});
|
||||
@@ -4,61 +4,178 @@ const amountName = "regionalSettlementAmountFromExternalProcessorBeforeRounding"
|
||||
const routingName = "settlementRoutingReferenceForCrossBorderReconciliation";
|
||||
const routingText = "APR-2026 / eu-west / batch-701 / settlement complete";
|
||||
const routingValue = "'" + routingText + "'";
|
||||
const invalidValueMessage = "The settlement amount must be a valid decimal expression.";
|
||||
|
||||
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1220, height: 760 });
|
||||
test.describe("a paused session with editable values", () => {
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1220, height: 760 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ amountName, routingName, routingValue, invalidValueMessage }) => {
|
||||
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 h = window.__ipc.handlers;
|
||||
let amountValue = "47.74";
|
||||
const amount = () => ({
|
||||
name: amountName,
|
||||
value: amountValue,
|
||||
typeName: "float",
|
||||
variablesReference: 0,
|
||||
evaluateName: amountName,
|
||||
});
|
||||
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
h.debug_variables = () => [
|
||||
amount(),
|
||||
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
|
||||
];
|
||||
h.debug_set_variable = ({ value }) => {
|
||||
if (value === "invalid") throw { kind: "invalid", message: invalidValueMessage, detail: null };
|
||||
amountValue = String(value);
|
||||
return amount();
|
||||
};
|
||||
adoptSession(91, {
|
||||
name: "Checkout",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 390);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ amountName, routingName, routingValue, invalidValueMessage },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
});
|
||||
|
||||
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const amount = debug.getByText("47.74", { exact: true });
|
||||
await expect
|
||||
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
|
||||
const show = routing.getByTitle("Show", { exact: true });
|
||||
await expect(show).toBeInViewport({ ratio: 1 });
|
||||
await show.click();
|
||||
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
|
||||
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 1640, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
|
||||
moveToolWindow("debug", "bottom");
|
||||
});
|
||||
await expect(show).toBeHidden();
|
||||
await expect
|
||||
.poll(() =>
|
||||
routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1),
|
||||
)
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
test("keeps the variable label and input in place when editing a value", async ({ workbench: page }) => {
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const row = debug.getByRole("treeitem").filter({ hasText: amountName });
|
||||
const name = row.getByText(amountName, { exact: true });
|
||||
await row.click();
|
||||
const nameBefore = (await name.boundingBox())!;
|
||||
const equal = row.getByText("=", { exact: true });
|
||||
const equalBefore = (await equal.boundingBox())!;
|
||||
const color = await name.evaluate((el) => getComputedStyle(el).color);
|
||||
|
||||
await page.keyboard.press("F2");
|
||||
const input = row.getByRole("textbox", { name: `New value of ${amountName}` });
|
||||
await expect(input).toBeFocused();
|
||||
await expect(input).toHaveValue("47.74");
|
||||
await expect(name).toHaveCSS("color", color);
|
||||
expect((await name.boundingBox())!.x).toBeCloseTo(nameBefore.x, 0);
|
||||
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
|
||||
await expect(row.locator("svg")).toHaveCount(1);
|
||||
|
||||
await input.fill("invalid");
|
||||
await input.press("Enter");
|
||||
await expect(input).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(input).toHaveAttribute("title", invalidValueMessage);
|
||||
await expect(input).toBeInViewport({ ratio: 1 });
|
||||
expect((await input.boundingBox())!.width).toBeGreaterThan(60);
|
||||
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
|
||||
|
||||
await input.press("Escape");
|
||||
await expect(input).toBeHidden();
|
||||
await expect(row).toContainText("47.74");
|
||||
|
||||
await page.keyboard.press("F2");
|
||||
await expect(input).toHaveValue("47.74");
|
||||
await input.fill("48.25");
|
||||
await input.press("Enter");
|
||||
await expect(input).toBeHidden();
|
||||
await expect(row).toContainText("48.25");
|
||||
});
|
||||
});
|
||||
|
||||
test("keeps a decimal value legible beside a long runtime type", async ({ workbench: page }) => {
|
||||
const name = "dailySettlementTotal";
|
||||
const type = "ExactSettlementAmountForCrossBorderReconciliation";
|
||||
const value = "12486245.8067";
|
||||
const countName = "pendingInvoices";
|
||||
await page.setViewportSize({ width: 1100, height: 720 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ amountName, routingName, routingValue }) => {
|
||||
async ({ name, type, value, countName }) => {
|
||||
const debugModule = "/src/features/debugger/state.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const servicesModule = "/src/workbench/contributions.ts";
|
||||
const serviceModule = "/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 h = window.__ipc.handlers;
|
||||
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
h.debug_variables = () => [
|
||||
{ name: amountName, value: "47.74", typeName: "float", variablesReference: 0, evaluateName: amountName },
|
||||
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ serviceModule);
|
||||
window.__ipc.handlers.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
window.__ipc.handlers.debug_variables = () => [
|
||||
{ name, value, typeName: type, variablesReference: 0, evaluateName: name },
|
||||
{ name: countName, value: "327", typeName: "int", variablesReference: 0, evaluateName: countName },
|
||||
];
|
||||
adoptSession(91, {
|
||||
name: "Checkout",
|
||||
adoptSession(92, {
|
||||
name: "Settlement",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
frames: [{ id: 11, name: "settle", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 390);
|
||||
setToolWindowSize("right", 280);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ amountName, routingName, routingValue },
|
||||
{ name, type, value, countName },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
const amount = debug.getByText("47.74", { exact: true });
|
||||
await expect
|
||||
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
|
||||
const show = routing.getByTitle("Show", { exact: true });
|
||||
await expect(show).toBeInViewport({ ratio: 1 });
|
||||
await show.click();
|
||||
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
|
||||
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
const variable = debug.getByRole("treeitem").filter({ hasText: name });
|
||||
const amount = variable.getByText(value, { exact: true });
|
||||
const annotation = variable.getByTitle(`{${type}}`, { exact: true });
|
||||
await expect(amount).toBeVisible();
|
||||
await expect.poll(() => amount.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(variable.getByTitle("Show", { exact: true })).toBeHidden();
|
||||
await expect(annotation).toBeVisible();
|
||||
|
||||
await page.setViewportSize({ width: 1640, height: 760 });
|
||||
const shortValueName = debug.getByText(countName, { exact: true });
|
||||
await expect.poll(() => shortValueName.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
await page.setViewportSize({ width: 1440, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
moveToolWindow("debug", "bottom");
|
||||
setToolWindowSize("bottom", 310);
|
||||
});
|
||||
await expect(show).toBeHidden();
|
||||
await expect
|
||||
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
await expect.poll(() => annotation.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -69,3 +69,49 @@ test("the bottom single row keeps a long selected tab visible alongside the hidd
|
||||
await pane.getByRole("tab", { name: shortFile, exact: true }).press("End");
|
||||
await expectCloseToFit(tab);
|
||||
});
|
||||
|
||||
test("same-name tabs keep the filename beside a shortened directory", async ({ workbench: page }) => {
|
||||
const filename = "AllocationRule.ts";
|
||||
const first = "qa";
|
||||
const second = "backoffice-reconciliation";
|
||||
await openSplit(page, [`${first}/${filename}`, `${second}/${filename}`], "top");
|
||||
await page.setViewportSize({ width: 900, height: 760 });
|
||||
|
||||
const pane = page.locator("section[data-pane-id]").filter({
|
||||
has: page.getByRole("tab").filter({ hasText: second }),
|
||||
});
|
||||
const selected = pane.getByRole("tab").filter({ hasText: second });
|
||||
await expect(selected).toHaveText(`${second}/${filename}`);
|
||||
await expectCloseToFit(selected);
|
||||
const directory = selected.getByText(`${second}/`, { exact: true });
|
||||
const name = selected.getByText(filename, { exact: true });
|
||||
await expect.poll(() => directory.evaluate((el) => el.clientWidth > 0 && el.scrollWidth > el.clientWidth)).toBe(true);
|
||||
await expect
|
||||
.poll(() =>
|
||||
name.evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return el.getBoundingClientRect().width >= text.getBoundingClientRect().width;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
await pane.getByRole("button", { name: "Show Hidden Tabs" }).click();
|
||||
const picker = page.getByRole("grid", { name: "Hidden Editor Tabs" });
|
||||
await expect(picker.getByRole("gridcell").filter({ hasText: `${first}/${filename}` })).toBeVisible();
|
||||
await page.keyboard.press("Enter");
|
||||
const firstTab = pane.getByRole("tab").filter({ hasText: first });
|
||||
await expectCloseToFit(firstTab);
|
||||
await expect
|
||||
.poll(() =>
|
||||
firstTab.getByText(`${first}/`, { exact: true }).evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return Math.abs(el.clientWidth - text.getBoundingClientRect().width);
|
||||
}),
|
||||
)
|
||||
.toBeLessThanOrEqual(1);
|
||||
|
||||
await firstTab.locator("..").getByRole("button", { name: "Close Tab", exact: true }).click();
|
||||
await expect(page.getByRole("tab", { name: filename, exact: true })).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
@@ -117,7 +117,7 @@ test("fits a wide graph and saved columns without horizontal scrolling", async (
|
||||
expect(await list.evaluate((element) => element.scrollLeft)).toBe(0);
|
||||
});
|
||||
|
||||
test("keeps ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
test("keeps expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
const branch = "origin/feature/workspace-settings";
|
||||
const tag = "v2.1";
|
||||
const summary = "Keep workspace settings and commit references visible ".repeat(4).trim();
|
||||
@@ -127,7 +127,7 @@ test("keeps ref names visible when a long commit subject competes for space", as
|
||||
const options = "/src/features/vcs/logOptions.ts";
|
||||
const { useGitLog } = await import(/* @vite-ignore */ log);
|
||||
const { useLogOptions } = await import(/* @vite-ignore */ options);
|
||||
useLogOptions.setState({ tagNames: true });
|
||||
useLogOptions.setState({ tagNames: true, compactRefs: false });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] });
|
||||
},
|
||||
|
||||
@@ -112,6 +112,57 @@ test("Git Log separates commit message typography from compact metadata", async
|
||||
await expect(author).toHaveCSS("font-size", "12px");
|
||||
});
|
||||
|
||||
test("compact Git Log refs give the subject room on either side", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 630, height: 720 });
|
||||
const refSubject = "Reconcile shipping credits";
|
||||
const longReference = "release-quarterly-settlement-and-backoffice-invoice-reconciliation";
|
||||
await page.evaluate(
|
||||
async ({ refSubject, longReference }) => {
|
||||
const optionsModule = "/src/features/vcs/logOptions.ts";
|
||||
const logModule = "/src/features/vcs/logStore.ts";
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsModule);
|
||||
const { useGitLog } = await import(/* @vite-ignore */ logModule);
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({
|
||||
commits: [{ ...first, summary: refSubject, message: refSubject, refs: [longReference] }, ...rest],
|
||||
});
|
||||
},
|
||||
{ refSubject, longReference },
|
||||
);
|
||||
const row = page.getByRole("listbox", { name: "Commits" }).getByRole("option").filter({ hasText: refSubject });
|
||||
const subject = row.getByText(refSubject, { exact: true });
|
||||
const ref = row.getByTitle(longReference, { exact: true });
|
||||
const expectLayout = async () => {
|
||||
await expect
|
||||
.poll(() =>
|
||||
subject.evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return el.getBoundingClientRect().width + 0.02 >= text.getBoundingClientRect().width;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
await expect
|
||||
.poll(() =>
|
||||
ref.evaluate((el) => {
|
||||
const refs = el.parentElement!;
|
||||
return refs.clientWidth / refs.parentElement!.clientWidth;
|
||||
}),
|
||||
)
|
||||
.toBeLessThanOrEqual(0.34);
|
||||
await expect(ref).toHaveCSS("font-size", "12px");
|
||||
await expect(subject).toHaveCSS("font-size", "13px");
|
||||
};
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x < (await ref.boundingBox())!.x).toBe(true);
|
||||
|
||||
await page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "View Options" }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "References on the Left" }).click();
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x > (await ref.boundingBox())!.x).toBe(true);
|
||||
});
|
||||
|
||||
test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => {
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" });
|
||||
|
||||
@@ -176,7 +176,29 @@ test("Push keeps commit subjects and changed files readable in a narrow window",
|
||||
await expect(input).toHaveValue("main");
|
||||
await expect(dialog.getByRole("button", { name: "Push", exact: true })).toBeInViewport();
|
||||
const details = dialog.getByRole("region", { name: "Commit details" });
|
||||
await expect(details).toContainText("Keep the new totals consistent with receipts.");
|
||||
await page.evaluate(async () => {
|
||||
const project = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ project);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18, fontWeight: 400, boldFontWeight: 700 },
|
||||
},
|
||||
});
|
||||
});
|
||||
const messageSubject = details.getByText(OUTGOING, { exact: true });
|
||||
const messageBody = details.getByText("Keep the new totals consistent with receipts.", { exact: true });
|
||||
await expect(messageSubject).toHaveCSS("font-weight", "700");
|
||||
await expect(messageBody).toHaveCSS("font-weight", "400");
|
||||
await expect(messageSubject).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-family", /Consolas/);
|
||||
const metadata = details.getByText(/Sam Rivera <sam@example\.com>/);
|
||||
await expect(metadata).toHaveCSS("font-size", "12px");
|
||||
await metadata.scrollIntoViewIfNeeded();
|
||||
await expect(metadata).toBeInViewport();
|
||||
expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
|
||||
|
||||
@@ -93,3 +93,42 @@ test("Recent Locations keeps all snippet lines visible when the editor font grow
|
||||
await expect(row.getByText("changed", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(filter).toBeFocused();
|
||||
});
|
||||
|
||||
test("Recent Locations shows each file name once with its parent directory", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const tracking = "/src/features/search/common/tracking.ts";
|
||||
const { useTracking } = await import(/* @vite-ignore */ tracking);
|
||||
const now = Date.now();
|
||||
useTracking.setState({
|
||||
locations: [
|
||||
["README.md", "# Shop API"],
|
||||
["packages/billing/Routes.ts", "registerBillingRoutes();"],
|
||||
["packages/checkout/Routes.ts", "registerCheckoutRoutes();"],
|
||||
].map(([path, snippet], index) => ({
|
||||
path: `/dev/acme-api/${path}`,
|
||||
line: 0,
|
||||
col: 0,
|
||||
changed: false,
|
||||
time: now - index * 60000,
|
||||
snippet: [snippet],
|
||||
snippetStart: 0,
|
||||
})),
|
||||
});
|
||||
});
|
||||
await openRecent(page, "recentLocations");
|
||||
const dialog = page.getByRole("dialog", { name: "Recent Locations", exact: true });
|
||||
const rows = dialog.getByRole("option");
|
||||
await expect(rows).toHaveCount(3);
|
||||
await expect(rows.filter({ hasText: "# Shop API" }).getByText("README.md", { exact: true })).toHaveCount(1);
|
||||
|
||||
const billing = rows.filter({ hasText: "registerBillingRoutes();" });
|
||||
const checkout = rows.filter({ hasText: "registerCheckoutRoutes();" });
|
||||
await expect(billing.getByText("packages/billing", { exact: true })).toBeVisible();
|
||||
await expect(checkout.getByText("packages/checkout", { exact: true })).toBeVisible();
|
||||
await expect(checkout.getByTitle("packages/checkout/Routes.ts", { exact: true })).toBeVisible();
|
||||
|
||||
await dialog.getByRole("textbox", { name: "Filter recent locations" }).fill("packages/checkout");
|
||||
await expect(rows).toHaveCount(1);
|
||||
await expect(rows.first()).toContainText("registerCheckoutRoutes();");
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("the workspace refactoring preview separates filenames from directories and keeps outcomes readable", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 420, height: 620 });
|
||||
await page.evaluate(async () => {
|
||||
const popupPath = "/src/editor/lsp/popupStore.ts";
|
||||
const editPath = "/src/editor/lsp/workspaceEdit.ts";
|
||||
const { openPopup } = await import(/* @vite-ignore */ popupPath);
|
||||
const { summarizeWorkspaceEdit } = await import(/* @vite-ignore */ editPath);
|
||||
const root = "/dev/acme-api";
|
||||
const edit = {
|
||||
range: { start: { line: 0, col: 0 }, end: { line: 0, col: 9 } },
|
||||
new_text: "postInvoice",
|
||||
};
|
||||
openPopup({
|
||||
kind: "preview",
|
||||
title: "Rename 'saveOrder' to 'postInvoice'",
|
||||
summary: summarizeWorkspaceEdit({
|
||||
files: [
|
||||
{ kind: "edit", path: `${root}/README.md`, edits: [edit] },
|
||||
{ kind: "edit", path: `${root}/packages/billing/src/Routes.ts`, edits: [edit, edit] },
|
||||
{ kind: "edit", path: `${root}/packages/checkout/src/Routes.ts`, edits: [edit] },
|
||||
{
|
||||
kind: "rename",
|
||||
from: `${root}/packages/checkout/src/Invoice.ts`,
|
||||
to: `${root}/packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
renameThemeClasses: "",
|
||||
confirmLabel: "Do Refactor",
|
||||
onConfirm: () => {
|
||||
document.body.dataset.refactorConfirmed = "true";
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Rename 'saveOrder' to 'postInvoice'" });
|
||||
const rows = dialog.getByRole("list", { name: "Changes" }).getByRole("listitem");
|
||||
await expect(rows).toHaveCount(4);
|
||||
await expect(dialog.getByText("4 occurrences in 4 files")).toBeVisible();
|
||||
const root = rows.filter({ hasText: "README.md" });
|
||||
await expect(root.getByText("README.md", { exact: true })).toHaveCount(1);
|
||||
|
||||
const billing = rows.filter({ hasText: "2 occurrences" });
|
||||
await expect(billing.getByText("Routes.ts", { exact: true })).toBeVisible();
|
||||
await expect(billing.getByText("packages/billing/src", { exact: true })).toBeVisible();
|
||||
await expect(billing.getByTitle("packages/billing/src/Routes.ts", { exact: true })).toBeVisible();
|
||||
const checkout = rows.filter({ hasText: "packages/checkout/src" }).filter({ hasText: "Routes.ts" });
|
||||
await expect(checkout.getByText("packages/checkout/src", { exact: true })).toBeVisible();
|
||||
|
||||
const rename = rows.filter({ hasText: "Invoice.ts" });
|
||||
const target = rename.getByText("→ InvoiceReconciliationForInternationalOrders.ts", { exact: true });
|
||||
await expect(target).toBeVisible();
|
||||
await expect(target).toHaveAttribute("title", "packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts");
|
||||
expect((await target.boundingBox())!.width).toBeGreaterThan(35);
|
||||
await expect(dialog.getByRole("button", { name: "Do Refactor", exact: true })).toBeInViewport();
|
||||
await dialog.getByRole("button", { name: "Do Refactor", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-refactor-confirmed", "true");
|
||||
});
|
||||
+164
@@ -76,6 +76,73 @@ test("⌃R runs the selected configuration and shows its output and exit", async
|
||||
expect(started).toMatchObject({ config: { id: "npm:dev", command: "npm", args: ["run", "dev"] } });
|
||||
});
|
||||
|
||||
test("expanded console folds stay reachable at the start of their rows", async ({ workbench: page }) => {
|
||||
const heading = "Reconciling orders for the overnight settlement and inventory reporting pipeline";
|
||||
await stubRun(
|
||||
page,
|
||||
[
|
||||
{
|
||||
kind: "stdout",
|
||||
text: [
|
||||
"TRACE Reused inventory connection",
|
||||
"TRACE Loaded warehouse configuration",
|
||||
heading,
|
||||
"TRACE Checked warehouse audit result",
|
||||
"TRACE Updated inventory snapshot",
|
||||
"Processed 24 orders",
|
||||
"",
|
||||
].join("\n"),
|
||||
},
|
||||
],
|
||||
null,
|
||||
);
|
||||
await page.evaluate(async () => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, console: { ...settings?.console, foldPatterns: ["TRACE "] } },
|
||||
});
|
||||
moveToolWindow("run", "right");
|
||||
setToolWindowSize("right", 320);
|
||||
});
|
||||
await page.keyboard.press("Control+r");
|
||||
const log = page.getByRole("region", { name: "Run", exact: true }).getByRole("log");
|
||||
const expand = log.getByTitle("Expand folded lines", { exact: true });
|
||||
const collapse = log.getByRole("button", { name: "Collapse folded lines", exact: true });
|
||||
await expect(expand).toHaveCount(2);
|
||||
|
||||
await expand.first().click();
|
||||
await expect(log.getByText("TRACE Reused inventory connection", { exact: true })).toBeVisible();
|
||||
await expect(collapse).toHaveCount(1);
|
||||
await collapse.press("Space");
|
||||
await expect(expand).toHaveCount(2);
|
||||
|
||||
await expand.first().press("Enter");
|
||||
await expect(collapse).toBeFocused();
|
||||
await expand.last().click();
|
||||
await expect(collapse).toHaveCount(2);
|
||||
for (const scrollLeft of [0, 120]) {
|
||||
await log.evaluate((element, x) => (element.scrollLeft = x), scrollLeft);
|
||||
expect(await log.evaluate((element) => element.scrollLeft)).toBe(scrollLeft);
|
||||
for (const control of await collapse.all()) {
|
||||
const aligned = await control.evaluate((button) => {
|
||||
const log = button.closest('[role="log"]')!.getBoundingClientRect();
|
||||
const row = button.closest("[data-index]")!.getBoundingClientRect();
|
||||
const box = button.getBoundingClientRect();
|
||||
return Math.abs(box.left - log.left) <= 1 && box.top >= row.top && box.bottom <= row.bottom + 1;
|
||||
});
|
||||
expect(aligned).toBe(true);
|
||||
}
|
||||
}
|
||||
await collapse.first().click();
|
||||
await collapse.first().click();
|
||||
await expect(expand).toHaveCount(2);
|
||||
expect(await ipcCalls(page, "run_stdin")).toEqual([]);
|
||||
});
|
||||
|
||||
test("⌘F2 stops a running process", async ({ workbench: page }) => {
|
||||
await stubRun(page, [{ kind: "stdout", text: "Watching for changes…\n" }], null);
|
||||
await page.keyboard.press("Control+r");
|
||||
@@ -122,6 +189,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…";
|
||||
@@ -284,6 +390,64 @@ test("test results keep counts, actions and selected output visible as the pane
|
||||
await expect(output).toContainText(message);
|
||||
});
|
||||
|
||||
test("test results keep elapsed time beside the counts", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1060, height: 740 });
|
||||
const lines = [
|
||||
"test_tax (test_ledger.CheckoutTests.test_tax) ... ok",
|
||||
"test_refund (test_ledger.CheckoutTests.test_refund) ... FAIL",
|
||||
"test_callback (test_ledger.CheckoutTests.test_callback) ... skipped 'Requires a callback'",
|
||||
"Ran 3 tests in 0.170s",
|
||||
"FAILED (failures=1, skipped=1)",
|
||||
];
|
||||
await stubRun(page, [{ kind: "stderr", text: lines.join("\n") + "\n" }], 1, {
|
||||
id: "django:checkout-tests",
|
||||
name: "Checkout tests",
|
||||
kind: "django-test",
|
||||
command: "python",
|
||||
args: ["manage.py", "test", "-v", "2"],
|
||||
isTest: true,
|
||||
});
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
const summary = run.getByRole("status").filter({ hasText: "1 failing" });
|
||||
const ignored = summary.getByText("1 ignored", { exact: true });
|
||||
const elapsed = summary.getByText("170 ms", { exact: true });
|
||||
await expect(elapsed).toBeVisible();
|
||||
for (const width of [1060, 540]) {
|
||||
await page.setViewportSize({ width, height: 740 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const [count, duration] = await Promise.all([ignored.boundingBox(), elapsed.boundingBox()]);
|
||||
return count && duration && Math.abs(count.y - duration.y) <= 1 ? duration.x - count.x - count.width : Infinity;
|
||||
})
|
||||
.toBeLessThanOrEqual(12);
|
||||
}
|
||||
await expect(summary).toHaveCSS("border-bottom-width", "2px");
|
||||
});
|
||||
|
||||
test("test results retain a running label after the first test starts", async ({ workbench: page }) => {
|
||||
const name = "TestCheckoutTotals";
|
||||
await stubRun(
|
||||
page,
|
||||
[{ kind: "stdout", text: JSON.stringify({ Package: "example.com/checkout", Action: "run", Test: name }) + "\n" }],
|
||||
null,
|
||||
{
|
||||
id: "go:checkout-tests",
|
||||
name: "Checkout tests",
|
||||
kind: "go",
|
||||
command: "go",
|
||||
args: ["test", "-json"],
|
||||
isTest: true,
|
||||
},
|
||||
);
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
await expect(run.getByRole("treeitem", { name: new RegExp(name) })).toBeVisible();
|
||||
const summary = run.getByRole("status").filter({ hasText: "Running…" });
|
||||
await expect(summary).toBeVisible();
|
||||
await expect(summary).toHaveCSS("border-bottom-width", "2px");
|
||||
});
|
||||
|
||||
test("test results group failure navigation and let users hide row durations", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 540, height: 740 });
|
||||
const first = "TestCheckoutTotalsWithTaxRoundingAndPendingRefunds";
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
for (const height of [990, 700, 560]) {
|
||||
test(`run configurations dialog keeps its toolbar and scrolls only inside the panes at ${height}px`, async ({
|
||||
test(`run configurations dialog keeps its toolbar and name visible while scrolling at ${height}px`, async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 900, height });
|
||||
@@ -62,9 +62,13 @@ async function resize(page: Page, dialog: Locator, dy: number) {
|
||||
async function checkScrolling(page: Page, dialog: Locator) {
|
||||
const body = dialog.locator("[data-dialog-body]");
|
||||
const list = dialog.getByRole("tree", { name: "Run configurations", exact: true });
|
||||
const form = dialog.locator('[class*="_editForm_"]');
|
||||
const form = dialog.locator('[class*="_formSettings_"]');
|
||||
const nameField = dialog.getByRole("textbox", { name: "Name", exact: true });
|
||||
await list.evaluate((el) => (el.scrollTop = 0));
|
||||
await form.evaluate((el) => (el.scrollTop = 0));
|
||||
// Measure once the dialog's opening animation has settled.
|
||||
await dialog.evaluate((el) => Promise.all(el.getAnimations().map((animation) => animation.finished)));
|
||||
const nameTop = (await nameField.boundingBox())!.y;
|
||||
await list.hover();
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
@@ -74,6 +78,8 @@ async function checkScrolling(page: Page, dialog: Locator) {
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => form.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
expect(await list.evaluate((el) => el.scrollTop)).toBe(listTop);
|
||||
expect((await nameField.boundingBox())!.y).toBeCloseTo(nameTop, 0);
|
||||
await expect(dialog.getByRole("checkbox", { name: /Store as project file/ })).toBeInViewport({ ratio: 1 });
|
||||
const overflow = await body.evaluate((el) => ({
|
||||
scroll: el.scrollHeight,
|
||||
client: el.clientHeight,
|
||||
|
||||
@@ -112,7 +112,7 @@ test("resizing the configuration dialog grows its panes and keeps the footer vis
|
||||
await expect(dialog.getByRole("tree", { name: "Run configurations", exact: true })).toBeVisible();
|
||||
await expect.poll(async () => (await content.boundingBox())!.height).toBeLessThan(initial);
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ test("Java, npm and Python forms fit narrow and zoomed content panes", async ({
|
||||
for (const width of [1024, 640, 520]) {
|
||||
await page.setViewportSize({ width, height: 820 });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
message: `${kind}, ${width}px, ${zoom * 100}%`,
|
||||
})
|
||||
.toBeLessThanOrEqual(1);
|
||||
@@ -204,7 +204,7 @@ for (const locale of ["en", "zh"]) {
|
||||
)
|
||||
.toMatchObject({ overflow: expect.any(Number), footerFits: true, footerVisible: true });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.toBeLessThanOrEqual(1);
|
||||
const tasks = dialog.getByRole("list");
|
||||
await tasks.scrollIntoViewIfNeeded();
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("keeps the current settings page name readable when the path is wider than the pane", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = settings.getByRole("textbox", { name: "Search settings" });
|
||||
await search.fill("Maven");
|
||||
const path = settings.getByLabel("Breadcrumb", { exact: true });
|
||||
const parent = path.getByText("Build, Execution, Deployment", { exact: true });
|
||||
const current = path.getByText("Maven", { exact: true });
|
||||
await expect(current).toBeVisible();
|
||||
await search.clear();
|
||||
|
||||
for (const width of [400, 560, 1120]) {
|
||||
await page.setViewportSize({ width, height: 720 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
current.evaluate((label) => {
|
||||
const box = label.getBoundingClientRect();
|
||||
const trail = label.closest("[aria-label=Breadcrumb]")!.getBoundingClientRect();
|
||||
return label.clientWidth >= label.scrollWidth && box.width > 0 && box.right <= trail.right + 1;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
}
|
||||
await expect(parent).toBeInViewport({ ratio: 1 });
|
||||
expect(await parent.evaluate((label) => label.scrollWidth <= label.clientWidth)).toBe(true);
|
||||
await settings.getByRole("button", { name: "Back", exact: true }).click();
|
||||
await expect(current).toBeHidden();
|
||||
await settings.getByRole("button", { name: "Forward", exact: true }).click();
|
||||
await expect(current).toBeVisible();
|
||||
});
|
||||
|
||||
test("dirty settings keep scope labels and navigation inside the page header", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Show Usages distinguishes same-named files without losing the line or snippet", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 480, height: 620 });
|
||||
await page.evaluate(async () => {
|
||||
const usages = "/src/features/code-insight/usages.ts";
|
||||
const { useUsagesPopup } = await import(/* @vite-ignore */ usages);
|
||||
const symbol = "submitOrder";
|
||||
useUsagesPopup.setState({
|
||||
open: true,
|
||||
anchor: { x: 30, y: 90 },
|
||||
symbol,
|
||||
groups: (
|
||||
[
|
||||
["/dev/acme-api/packages/billing/src/Routes.ts", "return submitOrder(invoice);"],
|
||||
["/dev/acme-api/packages/checkout/src/Routes.ts", "return submitOrder(cart);"],
|
||||
["/dev/acme-api/src/Worker.ts", "await submitOrder(job);"],
|
||||
] as const
|
||||
).map(([path, text]) => {
|
||||
const col = text.indexOf(symbol);
|
||||
return { path, usages: [{ path, line: 6, col, endCol: col + symbol.length, text }] };
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
|
||||
const rows = popup.getByRole("option");
|
||||
const billing = rows.filter({ hasText: "invoice" });
|
||||
const checkout = rows.filter({ hasText: "cart" });
|
||||
await expect(rows).toHaveCount(3);
|
||||
for (const [row, directory] of [
|
||||
[billing, "billing"],
|
||||
[checkout, "checkout"],
|
||||
] as const) {
|
||||
await expect(row.getByText("Routes.ts", { exact: true })).toBeVisible();
|
||||
const caption = row.getByText(directory, { exact: true });
|
||||
await expect(caption).toBeVisible();
|
||||
expect(await caption.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(row.getByText("7", { exact: true })).toBeVisible();
|
||||
await expect(row.locator("mark")).toHaveText("submitOrder");
|
||||
}
|
||||
|
||||
await expect(checkout.getByTitle("/dev/acme-api/packages/checkout/src/Routes.ts", { exact: true })).toBeVisible();
|
||||
await expect(rows.filter({ hasText: "Worker.ts" }).getByText("src", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
@@ -40,6 +40,7 @@ import { rootOfPath } from "@/platform/projectRoots";
|
||||
import { isVirtualUri } from "@/platform/virtualDocs";
|
||||
import { cornerInset } from "@/editor/core/cm/cornerInset";
|
||||
export { iconAreaSource, mapLineStart, type IconAreaSource } from "@/editor/core/cm/iconArea";
|
||||
export { disambiguateTitles } from "@/editor/core/model/tabTitles";
|
||||
export {
|
||||
invalidateNavigationProviders,
|
||||
navigationEpoch,
|
||||
|
||||
@@ -26,6 +26,12 @@ describe("disambiguateTitles", () => {
|
||||
expect(m.get("/r/a/d/f.ts")).toBe("d");
|
||||
});
|
||||
|
||||
it("distinguishes directory names that occur at different depths", () => {
|
||||
const paths = ["/r/prod/shared/f.ts", "/r/shared/prod/f.ts", "/r/test/shared/f.ts"];
|
||||
const labels = disambiguateTitles(paths);
|
||||
expect(paths.map((path) => labels.get(path))).toEqual(["prod/shared", "shared/prod", "test"]);
|
||||
});
|
||||
|
||||
it("ignores duplicates of the same path", () => {
|
||||
expect(disambiguateTitles(["/p/a/x.ts", "/p/a/x.ts"]).size).toBe(0);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* IDEA-style editor tab titles for files that share a name: the nearest parent
|
||||
* directory that tells them apart is shown after the name (`lib.rs — ide-lsp`
|
||||
* Directory hints for files that share a name: a distinguishing parent
|
||||
* directory is shown after the name (`lib.rs — ide-lsp`
|
||||
* for `crates/ide-lsp/src/lib.rs` next to `crates/ide-vcs/src/lib.rs`).
|
||||
*/
|
||||
|
||||
@@ -27,25 +27,24 @@ export function disambiguateTitles(paths: readonly string[], titleOf = baseName)
|
||||
for (const group of groups.values()) {
|
||||
if (group.length < 2) continue;
|
||||
const dirs = group.map(parents);
|
||||
const nameCounts = new Map<string, number>();
|
||||
const suffixCounts = new Map<string, number>();
|
||||
const suffixes = dirs.map((names) => {
|
||||
for (const name of new Set(names)) {
|
||||
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
|
||||
}
|
||||
let suffix = "";
|
||||
return names.map((name) => {
|
||||
suffix = suffix ? `${name}/${suffix}` : name;
|
||||
suffixCounts.set(suffix, (suffixCounts.get(suffix) ?? 0) + 1);
|
||||
return suffix;
|
||||
});
|
||||
});
|
||||
group.forEach((path, i) => {
|
||||
const own = dirs[i]!;
|
||||
let hint: string | null = null;
|
||||
for (let depth = 0; depth < own.length; depth++) {
|
||||
const seg = own[depth]!;
|
||||
if (dirs.every((other, j) => j === i || other[depth] !== seg)) {
|
||||
hint = seg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hint === null) {
|
||||
// No single directory is unique: the shortest distinguishing parent path.
|
||||
const suffix = (d: string[], k: number) => d.slice(0, k).reverse().join("/");
|
||||
for (let k = 2; k <= own.length && hint === null; k++) {
|
||||
const mine = suffix(own, k);
|
||||
if (dirs.every((other, j) => j === i || suffix(other, k) !== mine)) hint = mine;
|
||||
}
|
||||
}
|
||||
out.set(path, hint ?? (own.length ? own.slice().reverse().join("/") : "/"));
|
||||
const name = dirs[i]!.find((segment) => nameCounts.get(segment) === 1);
|
||||
const paths = suffixes[i]!;
|
||||
const hint = name ?? paths.find((suffix, depth) => depth > 0 && suffixCounts.get(suffix) === 1);
|
||||
out.set(path, hint ?? paths.at(-1) ?? "/");
|
||||
});
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -150,6 +150,28 @@
|
||||
.deprecated {
|
||||
text-decoration-line: line-through;
|
||||
}
|
||||
.tabPath {
|
||||
--tab-directory-min: min(5ch, 25%);
|
||||
display: flex;
|
||||
}
|
||||
.tabDirectory > span,
|
||||
.tabFilename {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.tabDirectory {
|
||||
flex: 0 1000 max-content;
|
||||
/* Leave space for a short prefix without stretching one that already fits. */
|
||||
width: var(--tab-directory-min);
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.tabDirectory > span {
|
||||
display: block;
|
||||
}
|
||||
.tabFilename {
|
||||
flex: none;
|
||||
max-width: calc(100% - var(--tab-directory-min));
|
||||
}
|
||||
.dupe {
|
||||
color: var(--fg-faint);
|
||||
margin-left: 4px;
|
||||
|
||||
@@ -219,15 +219,23 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
const pin = t.pinned ? <Icon name="pin" size={11} className={styles.pin} label="Pinned" /> : null;
|
||||
const file = t.input.kind === "file" && t.input.path ? files.get(t.input.path) : undefined;
|
||||
const title = markModified && dirty[i] ? `*${name}` : name;
|
||||
const prefix = t.input.kind === "file" && dupe ? (dupe.endsWith("/") ? dupe : `${dupe}/`) : null;
|
||||
return {
|
||||
id: t.id,
|
||||
label: (
|
||||
label: prefix ? (
|
||||
<span className={styles.tabPath}>
|
||||
<span className={styles.tabDirectory}>
|
||||
<span>{prefix}</span>
|
||||
</span>
|
||||
<span className={clsx(styles.tabFilename, file?.deprecated && styles.deprecated)}>{title}</span>
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
{file?.deprecated ? <span className={styles.deprecated}>{title}</span> : title}
|
||||
{dupe && <span className={styles.dupe}>{dupe}</span>}
|
||||
</>
|
||||
),
|
||||
text: dupe ? `${name} — ${dupe}` : name,
|
||||
text: prefix ? `${prefix}${name}` : dupe ? `${name} — ${dupe}` : name,
|
||||
icon: showFileIcon
|
||||
? t.input.kind === "file" && t.input.path
|
||||
? (tabIcons[i] ?? file?.icon)
|
||||
|
||||
@@ -532,20 +532,6 @@
|
||||
.renamePreview .previewList {
|
||||
overflow: visible;
|
||||
}
|
||||
.renamePreview .previewName {
|
||||
min-width: 0;
|
||||
max-width: 55%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.renamePreview .previewOp {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.renamePreview .previewWarning {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
@@ -571,23 +557,46 @@
|
||||
padding: 0 14px;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.previewName {
|
||||
color: var(--fg-emphasis);
|
||||
.previewFile {
|
||||
flex: 1 1 auto;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
}
|
||||
.previewPath {
|
||||
.previewName,
|
||||
.previewDirectory,
|
||||
.previewOp {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.previewName {
|
||||
flex: none;
|
||||
max-inline-size: 100%;
|
||||
color: var(--fg-emphasis);
|
||||
}
|
||||
.previewFile:has(.previewDirectory) .previewName {
|
||||
max-inline-size: 70%;
|
||||
}
|
||||
.previewDirectory {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
direction: rtl;
|
||||
}
|
||||
.previewOp,
|
||||
.previewCount {
|
||||
flex: none;
|
||||
font-size: var(--fs-small);
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.previewOp {
|
||||
max-inline-size: 55%;
|
||||
}
|
||||
.previewCount {
|
||||
flex: none;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.previewWarning {
|
||||
flex: none;
|
||||
|
||||
@@ -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",
|
||||
|
||||
+37
-29
@@ -22,7 +22,7 @@ import {
|
||||
selectableText,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { basename, relativeDir, relativePath, useProject } from "@/platform/project";
|
||||
import {
|
||||
closePopup,
|
||||
updatePopup,
|
||||
@@ -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}
|
||||
@@ -762,25 +761,34 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
|
||||
</ul>
|
||||
) : (
|
||||
<ul data-testid="refactor-preview" className={styles.previewList} aria-label={tx("Changes")}>
|
||||
{summary.entries.map((e) => (
|
||||
<li key={e.path} className={styles.previewRow}>
|
||||
<Icon name={fileIconName(basename(e.path), e.path)} size={14} className={styles.itemIcon} />
|
||||
<span className={styles.previewName} title={relativePath(root, e.path)}>
|
||||
{basename(e.path)}
|
||||
</span>
|
||||
<span className={styles.previewPath} title={relativePath(root, e.path)}>
|
||||
{relativePath(root, e.path)}
|
||||
</span>
|
||||
<span className={styles.spacer} />
|
||||
{e.operation === "rename" && e.to && <span className={styles.previewOp}>→ {basename(e.to)}</span>}
|
||||
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
|
||||
{e.edits > 0 && (
|
||||
<span className={styles.previewCount}>
|
||||
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
|
||||
{summary.entries.map((e) => {
|
||||
const name = basename(e.path);
|
||||
const directory = relativeDir(root, e.path);
|
||||
return (
|
||||
<li key={e.path} className={styles.previewRow}>
|
||||
<Icon name={fileIconName(name, e.path)} size={14} className={styles.itemIcon} />
|
||||
<span className={styles.previewFile} title={relativePath(root, e.path)}>
|
||||
<span className={styles.previewName}>{name}</span>
|
||||
{directory && (
|
||||
<span className={styles.previewDirectory}>
|
||||
<bdi>{directory}</bdi>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
{e.operation === "rename" && e.to && (
|
||||
<span className={styles.previewOp} title={relativePath(root, e.to)}>
|
||||
→ {basename(e.to)}
|
||||
</span>
|
||||
)}
|
||||
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
|
||||
{e.edits > 0 && (
|
||||
<span className={styles.previewCount}>
|
||||
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
|
||||
</span>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</Dialog>
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -94,10 +94,16 @@
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.fileName {
|
||||
.fileName,
|
||||
.directory {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.directory {
|
||||
flex: 0 2 auto;
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.line {
|
||||
overflow: hidden;
|
||||
text-align: right;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { create } from "zustand";
|
||||
import clsx from "clsx";
|
||||
import { EditorState, StateEffect, StateField } from "@codemirror/state";
|
||||
import { Decoration, EditorView } from "@codemirror/view";
|
||||
import { codePreviewExtensions } from "@/editor/api";
|
||||
import { codePreviewExtensions, disambiguateTitles } from "@/editor/api";
|
||||
import { basename } from "@/platform/project";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { Icon, IconButton, List, Popup, Select, Spinner, fileIconName, listNavigate } from "@/ui";
|
||||
@@ -86,6 +86,14 @@ function UsagesPopupInner() {
|
||||
const preview = useUsagesPopupPreview((s) => s.preview);
|
||||
const rowHeight = useRowHeight(ROW);
|
||||
const all = useMemo<Usage[]>(() => groups.flatMap((g) => g.usages), [groups]);
|
||||
const directories = useMemo(
|
||||
() =>
|
||||
disambiguateTitles(
|
||||
groups.map((g) => g.path),
|
||||
basename,
|
||||
),
|
||||
[groups],
|
||||
);
|
||||
const [filter, setFilter] = useState("");
|
||||
const accessOptions = useUsageAccessOptions();
|
||||
const items = useMemo(
|
||||
@@ -233,11 +241,10 @@ function UsagesPopupInner() {
|
||||
}
|
||||
renderItem={(u) => (
|
||||
<div className={styles.row} data-testid="usage-row" data-path={u.path} data-line={u.line}>
|
||||
<span className={styles.file}>
|
||||
<span className={styles.file} title={u.path}>
|
||||
<Icon name={fileIconName(basename(u.path), u.path)} size={16} className={styles.icon} />
|
||||
<span className={styles.fileName} title={u.path}>
|
||||
{basename(u.path)}
|
||||
</span>
|
||||
<span className={styles.fileName}>{basename(u.path)}</span>
|
||||
{directories.has(u.path) && <span className={styles.directory}>{directories.get(u.path)}</span>}
|
||||
</span>
|
||||
<span className={styles.line}>{u.line + 1}</span>
|
||||
<UsagePreview usage={u} />
|
||||
|
||||
@@ -293,7 +293,7 @@ describe("debug tool window", () => {
|
||||
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.getByRole("textbox", { name: "Evaluate expression" })).toBeTruthy();
|
||||
expect(screen.getByPlaceholderText("Evaluate expression (↩) or add a watch (⇧⌘↩)")).toBeTruthy();
|
||||
expect(await screen.findByText("{int}")).toBeTruthy();
|
||||
expect(screen.getByText("'hi'")).toBeTruthy();
|
||||
// A multi-line rendering stays on its row.
|
||||
|
||||
@@ -210,28 +210,14 @@
|
||||
}
|
||||
|
||||
.evalField {
|
||||
min-height: var(--h-field);
|
||||
height: 30px;
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-0-5) var(--space-1) var(--space-0-5) var(--space-2);
|
||||
background: var(--bg-input);
|
||||
padding: 0 4px 0 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.evalField:focus-within {
|
||||
box-shadow: inset 0 -1px var(--focus-ring);
|
||||
}
|
||||
.evalField > button {
|
||||
flex: none;
|
||||
}
|
||||
.evalField .evalInput {
|
||||
padding: 0;
|
||||
}
|
||||
.evalHistory {
|
||||
padding-block: var(--space-1);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.repl {
|
||||
height: 28px;
|
||||
|
||||
@@ -3,10 +3,6 @@ import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { monoFontFamily } from "@/platform/fonts";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { formatBinding, hostBinding } from "@/platform/keymap";
|
||||
import { basename, useProject } from "@/platform/project";
|
||||
import { call, commands, isTauri, type Scope, type Variable } from "@/platform/ipc";
|
||||
import {
|
||||
@@ -15,8 +11,6 @@ import {
|
||||
IconButton,
|
||||
Kbd,
|
||||
Menu,
|
||||
MenuList,
|
||||
Popup,
|
||||
Select,
|
||||
SplitGroup,
|
||||
SplitHandle,
|
||||
@@ -60,7 +54,6 @@ import { MemoryView } from "../memory/MemoryView";
|
||||
import { DebugConsole } from "./DebugConsole";
|
||||
import { VariablesView, type VarRoot } from "./VariablesView";
|
||||
import { useExpressionCompletion } from "./ExpressionCompletion";
|
||||
import { pushHistory, readHistory } from "./expressionHistory";
|
||||
import { sortVariables } from "../values";
|
||||
import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import { useToolWindowShown } from "@/workbench/contributions";
|
||||
@@ -562,12 +555,9 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
const watches = useDebug((s) => s.watches);
|
||||
const stopSeq = useDebug((s) => s.stopSeq);
|
||||
const variablesEpoch = useDebug((s) => s.variablesEpoch);
|
||||
const settings = useProject((s) => s.settings);
|
||||
const [expression, setExpression] = useState("");
|
||||
const evalField = useRef<HTMLInputElement>(null);
|
||||
const evalRow = useRef<HTMLDivElement>(null);
|
||||
const completion = useExpressionCompletion(evalField, expression, setExpression, session);
|
||||
const [history, setHistory] = useState<{ sessionId: number; stopSeq: number; entries: string[] } | null>(null);
|
||||
const [lastEval, setLastEval] = useState<EvalRow | null>(null);
|
||||
const [scopeData, setScopeData] = useState<{ frame: number | null; scopes: Scope[]; locals: Variable[] }>({
|
||||
frame: null,
|
||||
@@ -580,8 +570,6 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
rows: [],
|
||||
});
|
||||
const frame = session.status === "paused" ? session.selectedFrame : null;
|
||||
const historyOpen = frame != null && history?.sessionId === session.id && history.stopSeq === stopSeq;
|
||||
const editor = settings?.editor;
|
||||
const live = liveWatchesApply(session);
|
||||
// A hidden tool window stays mounted: its watches must not go on running in the page.
|
||||
const liveWatches = useLiveWatches(session, watches, useToolWindowShown());
|
||||
@@ -688,7 +676,6 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
const run = async () => {
|
||||
const e = expression.trim();
|
||||
if (!e) return;
|
||||
pushHistory("evaluate", e);
|
||||
try {
|
||||
setLastEval({
|
||||
expression: e,
|
||||
@@ -700,32 +687,12 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
}
|
||||
};
|
||||
|
||||
const addExpressionWatch = () => {
|
||||
const e = expression.trim();
|
||||
if (!e) return;
|
||||
pushHistory("evaluate", e);
|
||||
addWatch(e);
|
||||
setExpression("");
|
||||
};
|
||||
|
||||
const recall = (text: string) => {
|
||||
setExpression(text);
|
||||
requestAnimationFrame(() => {
|
||||
evalField.current?.focus();
|
||||
evalField.current?.setSelectionRange(text.length, text.length);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.variables}>
|
||||
<div ref={evalRow} className={styles.evalField}>
|
||||
<div className={styles.evalField}>
|
||||
<input
|
||||
ref={evalField}
|
||||
className={styles.evalInput}
|
||||
style={{
|
||||
fontFamily: monoFontFamily(editor?.fontFamily, editorPrefs(settings).fallbackFont, "var(--font-mono)"),
|
||||
fontSize: editor?.fontSize ? `min(var(--fs-ui), ${editor.fontSize}px)` : undefined,
|
||||
}}
|
||||
value={expression}
|
||||
onChange={(e) => {
|
||||
setExpression(e.target.value);
|
||||
@@ -733,16 +700,17 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
}}
|
||||
onBlur={completion.close}
|
||||
onKeyDown={(e) => {
|
||||
if (isImeKey(e.nativeEvent) || completion.onKeyDown(e)) return;
|
||||
if (completion.onKeyDown(e)) return;
|
||||
if (e.key === "Enter" && (e.metaKey || e.ctrlKey) && e.shiftKey) {
|
||||
e.preventDefault();
|
||||
addExpressionWatch();
|
||||
addWatch(expression);
|
||||
setExpression("");
|
||||
} else if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
void run();
|
||||
}
|
||||
}}
|
||||
placeholder={tx("Evaluate expression")}
|
||||
placeholder={frame != null ? "Evaluate expression (↩) or add a watch (⇧⌘↩)" : "Evaluate expression"}
|
||||
aria-label={tx("Evaluate expression")}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
@@ -752,55 +720,16 @@ function VariablesPane({ session }: { session: DebugSession }) {
|
||||
<IconButton
|
||||
icon="plus"
|
||||
title="Add to Watches"
|
||||
shortcut={formatBinding(hostBinding("Meta+Shift+Enter"))}
|
||||
shortcut="⇧⌘↩"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
disabled={!expression.trim()}
|
||||
onClick={addExpressionWatch}
|
||||
/>
|
||||
<IconButton
|
||||
icon="chevron-down"
|
||||
title="History"
|
||||
size="small"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={historyOpen}
|
||||
disabled={frame == null}
|
||||
onClick={() =>
|
||||
setHistory(
|
||||
historyOpen
|
||||
? null
|
||||
: {
|
||||
sessionId: session.id,
|
||||
stopSeq,
|
||||
entries: readHistory("evaluate")
|
||||
.filter((entry) => !/[\r\n]/.test(entry))
|
||||
.slice(0, 20),
|
||||
},
|
||||
)
|
||||
}
|
||||
onClick={() => {
|
||||
addWatch(expression);
|
||||
setExpression("");
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Popup
|
||||
open={historyOpen}
|
||||
onClose={() => setHistory(null)}
|
||||
anchor={evalRow}
|
||||
placement="bottom-start"
|
||||
matchWidth
|
||||
role="presentation"
|
||||
autoFocus={false}
|
||||
className={styles.evalHistory}
|
||||
>
|
||||
<MenuList
|
||||
aria-label={tx("Expression history")}
|
||||
iconColumn={false}
|
||||
onDone={() => setHistory(null)}
|
||||
items={
|
||||
history?.entries.length
|
||||
? history.entries.map((entry) => ({ label: entry, verbatim: true, run: () => recall(entry) }))
|
||||
: [{ label: "No history", disabled: true }]
|
||||
}
|
||||
/>
|
||||
</Popup>
|
||||
{frame == null && !watches.length && !lastEval ? (
|
||||
<div className={styles.note}>
|
||||
{session.status === "terminated"
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: min(8ch, 45%);
|
||||
/* Cap the automatic flex minimum at the space needed for a short preview. */
|
||||
width: min(14ch, 50%);
|
||||
flex: 1 1 0;
|
||||
}
|
||||
|
||||
@@ -135,9 +136,8 @@
|
||||
}
|
||||
|
||||
.type {
|
||||
min-width: 0;
|
||||
max-width: 25%;
|
||||
flex: 0 1 auto;
|
||||
min-width: min(3ch, 10%);
|
||||
flex: 0 4 auto;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg-subtle);
|
||||
@@ -159,11 +159,17 @@
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.editRow,
|
||||
.editRow > .valueGroup {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.editInput {
|
||||
flex: 1;
|
||||
min-width: min(80px, 40%);
|
||||
height: 18px;
|
||||
padding: 0 4px;
|
||||
box-sizing: border-box;
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
height: calc(100% - var(--space-1));
|
||||
padding: 0 var(--space-1);
|
||||
font: inherit;
|
||||
font-family: var(--font-mono);
|
||||
color: var(--fg-strong);
|
||||
@@ -176,6 +182,10 @@
|
||||
border-color: var(--danger);
|
||||
}
|
||||
|
||||
.editError {
|
||||
max-width: 33%;
|
||||
}
|
||||
|
||||
/* Changed since the previous stop. */
|
||||
.name.changed {
|
||||
color: var(--debug-changed, var(--link));
|
||||
|
||||
@@ -467,6 +467,7 @@ export function VariablesView({
|
||||
editing?.key === n.key ? (
|
||||
<VarEditRow
|
||||
node={n}
|
||||
changed={isChanged(n)}
|
||||
value={editing.value}
|
||||
error={editing.error}
|
||||
onChange={(value) => setEditing({ ...editing, value, error: null })}
|
||||
@@ -558,6 +559,7 @@ function ValueDialog({
|
||||
|
||||
function VarEditRow({
|
||||
node,
|
||||
changed,
|
||||
value,
|
||||
error,
|
||||
onChange,
|
||||
@@ -565,6 +567,7 @@ function VarEditRow({
|
||||
onCancel,
|
||||
}: {
|
||||
node: VarNode;
|
||||
changed: boolean;
|
||||
value: string;
|
||||
error: string | null;
|
||||
onChange: (v: string) => void;
|
||||
@@ -575,37 +578,36 @@ function VarEditRow({
|
||||
// the global "Escape → focus editor" binding (`!popupOpen`) from firing.
|
||||
useEffect(() => acquirePopup(), []);
|
||||
return (
|
||||
<span className={styles.row}>
|
||||
<span className={styles.name} title={node.name}>
|
||||
{node.name}
|
||||
<span className={clsx(styles.row, styles.editRow)} title={node.name}>
|
||||
<VarPrefix node={node} changed={changed} />
|
||||
<span className={styles.valueGroup}>
|
||||
<input
|
||||
className={clsx(styles.editInput, error && styles.editInvalid)}
|
||||
value={value}
|
||||
autoFocus
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
aria-label={`New value of ${node.name}`}
|
||||
aria-invalid={!!error || undefined}
|
||||
title={error ?? undefined}
|
||||
onFocus={(e) => e.currentTarget.select()}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
onBlur={onCancel}
|
||||
onKeyDown={(e) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
onCommit();
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
onCancel();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{error && <span className={clsx(styles.error, styles.editError)}>{oneLine(error)}</span>}
|
||||
</span>
|
||||
<span className={styles.eq}>=</span>
|
||||
<input
|
||||
className={clsx(styles.editInput, error && styles.editInvalid)}
|
||||
value={value}
|
||||
autoFocus
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
aria-label={`New value of ${node.name}`}
|
||||
aria-invalid={!!error || undefined}
|
||||
title={error ?? undefined}
|
||||
onFocus={(e) => e.currentTarget.select()}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
onDoubleClick={(e) => e.stopPropagation()}
|
||||
onBlur={onCancel}
|
||||
onKeyDown={(e) => {
|
||||
e.stopPropagation();
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
onCommit();
|
||||
} else if (e.key === "Escape") {
|
||||
e.preventDefault();
|
||||
onCancel();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{error && <span className={styles.error}>{error}</span>}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -616,6 +618,31 @@ function nodeIcon(node: VarNode): string {
|
||||
return node.depth0 ? "variable" : "field";
|
||||
}
|
||||
|
||||
function VarPrefix({ node, changed, showName = true }: { node: VarNode; changed: boolean; showName?: boolean }) {
|
||||
const evaluation = node.kind === "eval";
|
||||
return (
|
||||
<>
|
||||
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
|
||||
{showName && (
|
||||
<>
|
||||
<span
|
||||
className={clsx(
|
||||
styles.name,
|
||||
evaluation && styles.evalName,
|
||||
node.kind === "var" && styles.varName,
|
||||
changed && styles.changed,
|
||||
)}
|
||||
title={evaluation ? node.name : undefined}
|
||||
>
|
||||
{evaluation ? oneLine(node.name) : node.name}
|
||||
</span>
|
||||
<span className={styles.eq}>=</span>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function VarRow({
|
||||
node,
|
||||
changed,
|
||||
@@ -655,26 +682,9 @@ function VarRow({
|
||||
);
|
||||
const kind = node.error ? null : classifyValue(node.value, node.typeName);
|
||||
const shown = shownValue(node.value, node.typeName);
|
||||
const evaluation = node.kind === "eval";
|
||||
return (
|
||||
<span className={styles.row} title={node.name}>
|
||||
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
|
||||
{!shown.entry && (
|
||||
<>
|
||||
<span
|
||||
className={clsx(
|
||||
styles.name,
|
||||
evaluation && styles.evalName,
|
||||
node.kind === "var" && styles.varName,
|
||||
changed && styles.changed,
|
||||
)}
|
||||
title={evaluation ? node.name : undefined}
|
||||
>
|
||||
{evaluation ? oneLine(node.name) : node.name}
|
||||
</span>
|
||||
<span className={styles.eq}>=</span>
|
||||
</>
|
||||
)}
|
||||
<VarPrefix node={node} changed={changed} showName={!shown.entry} />
|
||||
{node.error ? (
|
||||
<span className={styles.error}>{oneLine(node.error)}</span>
|
||||
) : (
|
||||
|
||||
@@ -507,7 +507,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
{config.kind === "tomcat" ? (
|
||||
<TomcatSettings config={config} onChange={onChange} />
|
||||
) : (
|
||||
<>
|
||||
<div className={styles.formSettings}>
|
||||
{!noProcess && (
|
||||
<Field
|
||||
label="Run on"
|
||||
@@ -860,7 +860,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -143,7 +143,10 @@ export function foldRows(
|
||||
const fold: Fold = { start: i, count: j - i, id: lines[i]!.id, expanded: expanded.has(lines[i]!.id) };
|
||||
const prev = rows[rows.length - 1];
|
||||
if (prev?.kind === "line") prev.fold = fold;
|
||||
else if (!fold.expanded) rows.push({ kind: "fold", fold });
|
||||
else if (fold.expanded) {
|
||||
rows.push({ kind: "line", index: i, fold });
|
||||
i++;
|
||||
} else rows.push({ kind: "fold", fold });
|
||||
if (fold.expanded) for (; i < j; i++) rows.push({ kind: "line", index: i });
|
||||
i = j;
|
||||
continue;
|
||||
@@ -230,7 +233,7 @@ export function ConsoleView({
|
||||
// Pending input continues the open line (a prompt), or starts a row of its own.
|
||||
const lastRow = folded[folded.length - 1];
|
||||
const inputInline =
|
||||
!!input && !!model.openLine && lastRow?.kind === "line" && !lastRow.fold && lines[lastRow.index] === model.openLine;
|
||||
!!input && !!model.openLine && lastRow?.kind === "line" && lines[lastRow.index] === model.openLine;
|
||||
const inputRow = !!input && !inputInline;
|
||||
const [widest] = useState(() => new WidestColumns());
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- `version` marks in-place appends to `lines`
|
||||
@@ -255,7 +258,7 @@ export function ConsoleView({
|
||||
getItemKey: (i) => {
|
||||
const r = rows[i];
|
||||
if (!r) return "input";
|
||||
return r.kind === "fold" ? `f${r.fold.id}` : (lines[r.index]?.id ?? i);
|
||||
return r.kind === "fold" ? r.fold.id : (lines[r.index]?.id ?? i);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -486,7 +489,7 @@ export function ConsoleView({
|
||||
return;
|
||||
}
|
||||
if (copySelectionOnKeyDown(e, selectedOutput)) return;
|
||||
if (!input) return;
|
||||
if (!input || e.target instanceof HTMLButtonElement) return;
|
||||
if (e.key === "d" && e.ctrlKey && !e.metaKey && !e.altKey) {
|
||||
e.preventDefault();
|
||||
input.onEof();
|
||||
@@ -523,19 +526,24 @@ export function ConsoleView({
|
||||
const foldButton = (fold: Fold, attached: boolean) =>
|
||||
fold.expanded ? (
|
||||
<button
|
||||
key={fold.id}
|
||||
type="button"
|
||||
className={styles.foldToggle}
|
||||
style={{ height: rowHeight }}
|
||||
title={tx("Collapse folded lines")}
|
||||
aria-label={tx("Collapse folded lines")}
|
||||
aria-expanded={true}
|
||||
onClick={() => toggleFold(fold.id)}
|
||||
>
|
||||
<Icon name="chevron-up" size={10} />
|
||||
<Icon name="chevron-down" size={10} />
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
key={fold.id}
|
||||
type="button"
|
||||
className={styles.fold}
|
||||
title={tx("Expand folded lines")}
|
||||
aria-expanded={false}
|
||||
onClick={() => toggleFold(fold.id)}
|
||||
>
|
||||
{`${attached ? " " : ""}${fold.count === 1 ? tx`<${fold.count} internal line>` : tx`<${fold.count} internal lines>`}`}
|
||||
@@ -651,6 +659,7 @@ export function ConsoleView({
|
||||
className={clsx(styles.line, styles[line.kind])}
|
||||
style={{ ...rowStyle(item.start), color, background: ruled?.line?.bg }}
|
||||
>
|
||||
{row.fold?.expanded && foldButton(row.fold, false)}
|
||||
<Line
|
||||
line={line}
|
||||
marks={marksByLine.get(row.index)}
|
||||
@@ -658,7 +667,7 @@ export function ConsoleView({
|
||||
length={line.text.length}
|
||||
cwd={cwd}
|
||||
/>
|
||||
{row.fold && foldButton(row.fold, true)}
|
||||
{row.fold && !row.fold.expanded && foldButton(row.fold, true)}
|
||||
{inputInline && item.index === rows.length - 1 && pendingInput}
|
||||
{"\n"}
|
||||
</div>
|
||||
|
||||
@@ -212,7 +212,7 @@
|
||||
top: 0;
|
||||
left: 0;
|
||||
min-width: 100%;
|
||||
padding: 0 12px;
|
||||
padding: 0 var(--space-3);
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
tab-size: 4;
|
||||
@@ -258,12 +258,12 @@
|
||||
.testStatusBar {
|
||||
flex: none;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
min-height: 28px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.testToolbar {
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-0-5) var(--space-1);
|
||||
}
|
||||
@@ -275,27 +275,36 @@
|
||||
border-inline-end: 1px solid var(--border);
|
||||
}
|
||||
.testStatusBar {
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-0-5) var(--space-2);
|
||||
border-block-end-width: var(--space-0-5);
|
||||
font-size: var(--fs-ui);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
.testStatusBar[data-outcome="passed"] {
|
||||
border-block-end-color: var(--success);
|
||||
}
|
||||
.testStatusBar[data-outcome="skipped"] {
|
||||
border-block-end-color: var(--warning);
|
||||
}
|
||||
.testStatusBar[data-running] {
|
||||
border-block-end-color: var(--accent);
|
||||
}
|
||||
.testStatusBar[data-outcome="failed"] {
|
||||
border-block-end-color: var(--danger);
|
||||
}
|
||||
.testCounts {
|
||||
flex: 1 1 auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.testStatus,
|
||||
.testTotalDuration {
|
||||
.testStatus {
|
||||
flex: none;
|
||||
}
|
||||
.testTotalDuration {
|
||||
margin-left: auto;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.testTree {
|
||||
@@ -665,22 +674,39 @@
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.configFields {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(40%) minmax(0, 1fr);
|
||||
grid-template-rows: [notice] auto [header] auto [options] minmax(0, 1fr);
|
||||
column-gap: var(--space-3);
|
||||
row-gap: var(--space-2);
|
||||
align-content: start;
|
||||
min-width: 0;
|
||||
}
|
||||
.configFields > * {
|
||||
.configFields > *,
|
||||
.formSettings > * {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .field,
|
||||
.configFields > .notice {
|
||||
grid-row: notice;
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .notice,
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader {
|
||||
margin-bottom: var(--space-2);
|
||||
}
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader,
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader > .field {
|
||||
.configFields:not(.configFieldsTomcat) > .formHeader > .field,
|
||||
.formSettings > .field {
|
||||
grid-template-columns: subgrid;
|
||||
}
|
||||
.formSettings {
|
||||
display: grid;
|
||||
grid-row: options;
|
||||
grid-template-columns: subgrid;
|
||||
row-gap: var(--space-2);
|
||||
align-content: start;
|
||||
overflow: auto;
|
||||
}
|
||||
.formHeader > .field {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
@@ -688,8 +714,6 @@
|
||||
overflow: hidden;
|
||||
}
|
||||
.configFieldsTomcat {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
@@ -793,6 +817,7 @@
|
||||
}
|
||||
.formHeader {
|
||||
display: grid;
|
||||
grid-row: header;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
@@ -1118,15 +1143,19 @@
|
||||
color: var(--fg);
|
||||
}
|
||||
.foldToggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 6px;
|
||||
padding: 0 2px;
|
||||
position: sticky;
|
||||
inset-inline-start: 0;
|
||||
z-index: 1;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: var(--space-3);
|
||||
margin-inline-start: calc(-1 * var(--space-3));
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
background: none;
|
||||
border-radius: var(--radius-small);
|
||||
background: var(--bg-app);
|
||||
color: var(--fg-faint);
|
||||
vertical-align: middle;
|
||||
vertical-align: top;
|
||||
cursor: pointer;
|
||||
}
|
||||
.foldToggle:hover {
|
||||
|
||||
@@ -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}>
|
||||
|
||||
@@ -112,27 +112,24 @@ export function TestStatusBar({
|
||||
running: boolean;
|
||||
}) {
|
||||
const counts = useMemo(() => results.counts(), [results, version]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
const status = running
|
||||
? "running"
|
||||
: counts.failed
|
||||
? "failed"
|
||||
: counts.passed
|
||||
? "passed"
|
||||
: counts.skipped
|
||||
? "skipped"
|
||||
: null;
|
||||
const outcome = counts.failed ? "failed" : counts.passed ? "passed" : counts.skipped ? "skipped" : null;
|
||||
const duration = results.summary.durationMs;
|
||||
|
||||
return (
|
||||
<div className={styles.testStatusBar} role="status">
|
||||
<StatusIcon status={status} />
|
||||
<div
|
||||
className={styles.testStatusBar}
|
||||
role="status"
|
||||
data-running={running || undefined}
|
||||
data-outcome={outcome ?? undefined}
|
||||
>
|
||||
<StatusIcon status={running ? "running" : outcome} />
|
||||
<span className={styles.testCounts}>
|
||||
{counts.failed > 0 && <span className={styles.failed}>{tx`${counts.failed} failing`}</span>}
|
||||
{counts.passed > 0 && <span>{tx`${counts.passed} passed`}</span>}
|
||||
{counts.skipped > 0 && <span className={styles.skipped}>{tx`${counts.skipped} ignored`}</span>}
|
||||
{counts.total === 0 && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
|
||||
{!outcome && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
|
||||
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
|
||||
</span>
|
||||
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ import { call, commands, type OutlineItem } from "@/platform/ipc";
|
||||
import { monoFontFamily } from "@/platform/fonts";
|
||||
import { shortcutLabel } from "@/platform/keymap";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
|
||||
import {
|
||||
Checkbox,
|
||||
Dialog,
|
||||
@@ -40,7 +41,7 @@ import {
|
||||
type ToolWindowContribution,
|
||||
} from "@/workbench/contributions";
|
||||
import { highlightTokens, languageForPath, type CodeToken } from "@/editor/lsp/markdown";
|
||||
import { basename, openInListOrder, openLocation } from "../common/open";
|
||||
import { basename, openInListOrder, openLocation, relDir } from "../common/open";
|
||||
import { outlinePathAt } from "../structure/outline";
|
||||
import { fromNavigationHistory, isDismissed, mergeLocations, type RecentLocation } from "../common/locations";
|
||||
import { dismissLocation, useTracking } from "../common/tracking";
|
||||
@@ -688,33 +689,39 @@ function RecentLocationsDialog() {
|
||||
rowHeight={rowHeight}
|
||||
aria-label="Recent locations"
|
||||
empty={<span>{changedOnly ? tx("No changed locations") : tx("No recent locations")}</span>}
|
||||
renderItem={(l) => (
|
||||
<div className={styles.location}>
|
||||
<div className={styles.locationHeader}>
|
||||
<Icon name={fileIconName(basename(l.rel), l.rel)} size={14} className={styles.icon} />
|
||||
<HighlightedText
|
||||
className={clsx(styles.name, styles.locationName)}
|
||||
text={basename(l.rel)}
|
||||
indices={l.nameIndices}
|
||||
tone="strong"
|
||||
renderItem={(l) => {
|
||||
const name = basename(l.rel);
|
||||
const breadcrumb = breadcrumbOf(outlines.get(l.path), l);
|
||||
const directory = isVirtualUri(l.path) ? virtualContainer(l.path) : relDir(l.rel);
|
||||
const context = breadcrumb && breadcrumb !== name ? breadcrumb : directory;
|
||||
return (
|
||||
<div className={styles.location}>
|
||||
<div className={styles.locationHeader} title={l.rel}>
|
||||
<Icon name={fileIconName(name, l.rel)} size={14} className={styles.icon} />
|
||||
<HighlightedText
|
||||
className={clsx(styles.name, styles.locationName)}
|
||||
text={name}
|
||||
indices={l.nameIndices}
|
||||
tone="strong"
|
||||
/>
|
||||
{context && <span className={styles.dir}>{context}</span>}
|
||||
{l.changed && (
|
||||
<span className={styles.changed}>
|
||||
<T>changed</T>
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.time}>{locationTime(l.time, now)}</span>
|
||||
</div>
|
||||
<SnippetCode
|
||||
path={l.path}
|
||||
lines={dedent(l.snippet)}
|
||||
first={l.snippetStart}
|
||||
caret={l.line}
|
||||
style={snippetStyle}
|
||||
/>
|
||||
<span className={styles.dir}>{breadcrumbOf(outlines.get(l.path), l) || l.rel}</span>
|
||||
{l.changed && (
|
||||
<span className={styles.changed}>
|
||||
<T>changed</T>
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.time}>{locationTime(l.time, now)}</span>
|
||||
</div>
|
||||
<SnippetCode
|
||||
path={l.path}
|
||||
lines={dedent(l.snippet)}
|
||||
first={l.snippetStart}
|
||||
caret={l.line}
|
||||
style={snippetStyle}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
@@ -101,19 +101,28 @@
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
.crumb:last-child {
|
||||
.parentCrumbs {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
}
|
||||
.crumb > span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.crumb {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
.crumbLabel {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.currentCrumb {
|
||||
flex: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
.crumbSep {
|
||||
margin: 0 4px;
|
||||
flex: none;
|
||||
margin-inline: var(--space-1);
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.reset {
|
||||
|
||||
@@ -165,21 +165,29 @@ function PageHost({
|
||||
const [headerSlot, setHeaderSlot] = useState<HTMLElement | null>(null);
|
||||
if (!node) return <EmptyState title="Nothing found" icon="search" />;
|
||||
const Body = page?.component;
|
||||
const parents = crumbs.slice(0, -1);
|
||||
return (
|
||||
<PageContext.Provider value={ctx}>
|
||||
<SettingsFormContext.Provider value={form}>
|
||||
<SettingsPageFocusContext.Provider value={pageFocus}>
|
||||
<SettingsHeaderSlotContext.Provider value={headerSlot}>
|
||||
<div className={styles.pageHeader}>
|
||||
<div className={styles.crumbs} aria-label={tx("Breadcrumb")}>
|
||||
{crumbs.map((c, i) => (
|
||||
<span key={i} className={styles.crumb}>
|
||||
{i > 0 && <Icon name="chevron-right" size={12} className={styles.crumbSep} />}
|
||||
<span>
|
||||
<T>{c}</T>
|
||||
</span>
|
||||
<div className={styles.crumbs} aria-label={tx("Breadcrumb")} title={crumbs.map((c) => tx(c)).join(" › ")}>
|
||||
{parents.length > 0 && (
|
||||
<span className={styles.parentCrumbs}>
|
||||
{parents.map((c, i) => (
|
||||
<span key={i} className={styles.crumb}>
|
||||
<span className={styles.crumbLabel}>
|
||||
<T>{c}</T>
|
||||
</span>
|
||||
<Icon name="chevron-right" size={12} className={styles.crumbSep} />
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
))}
|
||||
)}
|
||||
<span className={clsx(styles.crumbLabel, styles.currentCrumb)} aria-current="page">
|
||||
<T>{node.title}</T>
|
||||
</span>
|
||||
</div>
|
||||
<div ref={setHeaderSlot} className={styles.headerSlot} />
|
||||
{dirty && (
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import type { Commit } from "@/bindings";
|
||||
import type { ReactNode } from "react";
|
||||
import { fontWeightOf } from "@/platform/editorSettings";
|
||||
import { resolveMonoFont } from "@/platform/fonts";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import styles from "./GitLog.module.css";
|
||||
|
||||
export function CommitMessageContent({
|
||||
commit,
|
||||
message,
|
||||
compact = false,
|
||||
renderText = (text) => text,
|
||||
revision = commit.shortId,
|
||||
}: {
|
||||
commit: Commit;
|
||||
message: string;
|
||||
compact?: boolean;
|
||||
renderText?: (text: string) => ReactNode;
|
||||
revision?: ReactNode;
|
||||
}) {
|
||||
const editor = useProject((s) => s.settings?.editor);
|
||||
const { family, size } = resolveMonoFont(undefined, editor);
|
||||
const [subject = "", ...bodyLines] = message.trimEnd().split("\n");
|
||||
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={styles.messageText}
|
||||
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
|
||||
>
|
||||
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
|
||||
{renderText(subject)}
|
||||
</div>
|
||||
{body && <div className={styles.fullMessage}>{renderText(body)}</div>}
|
||||
</div>
|
||||
<div className={styles.meta}>
|
||||
{revision} {commit.author} <{commit.email}>
|
||||
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -405,9 +405,12 @@
|
||||
.subject {
|
||||
flex: 0 1 auto;
|
||||
min-width: var(--log-subject-min);
|
||||
color: var(--fg);
|
||||
}
|
||||
.subjectText {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: var(--fg);
|
||||
}
|
||||
.headSubject {
|
||||
font-weight: 600;
|
||||
@@ -437,6 +440,22 @@
|
||||
flex: none;
|
||||
max-width: calc(100% - var(--log-subject-min) - var(--space-1-5));
|
||||
}
|
||||
.commitText > .refsCompact {
|
||||
flex: 0 1 auto;
|
||||
max-width: calc(100% / 3);
|
||||
}
|
||||
.commitText:has(> .refsCompact) > .subject {
|
||||
/* Protect a short subject while leaving room for compact reference names. */
|
||||
flex: 0 1000 max-content;
|
||||
min-width: auto;
|
||||
width: min(75%, 24ch);
|
||||
}
|
||||
.commitText > .refs .ref {
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.refsCompact .ref {
|
||||
min-width: 11px;
|
||||
}
|
||||
.refsLeft {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { executeAction } from "@/platform/actions";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { Button, IconButton, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
|
||||
import { CommitMessageContent } from "./CommitMessageContent";
|
||||
import { ComparisonTree } from "./ComparisonTree";
|
||||
import { buildFileTree } from "./fileTree";
|
||||
import { flatFileNodes, toLogChanges, type LogChange } from "./logChanges";
|
||||
@@ -151,14 +152,9 @@ export function PushChanges({
|
||||
|
||||
/** The selected commit's full message, revision, author and time. */
|
||||
function PushCommitDetails({ commit }: { commit: Commit }) {
|
||||
const date = commit.timeMs ? new Date(commit.timeMs).toLocaleString() : null;
|
||||
return (
|
||||
<section className={styles.pushCommitDetails} aria-label={tx("Commit details")}>
|
||||
<div className={styles.pushCommitMessage}>{commit.message.trimEnd() || commit.summary}</div>
|
||||
<div className={styles.fileDir}>
|
||||
{commit.shortId} {commit.author} <{commit.email}>
|
||||
{date ? " " + tx`on ${date}` : ""}
|
||||
</div>
|
||||
<CommitMessageContent commit={commit} message={commit.message.trimEnd() || commit.summary} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { FileStatus } from "@/bindings";
|
||||
|
||||
const stage = vi.hoisted(() => vi.fn(async () => ({ status: "ok", data: null })));
|
||||
const ignore = vi.hoisted(() => vi.fn(async () => ({ status: "ok", data: [] })));
|
||||
const notify = vi.hoisted(() => vi.fn());
|
||||
const project = vi.hoisted(() => ({ paths: [] as string[] }));
|
||||
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...real,
|
||||
commands: {
|
||||
...real.commands,
|
||||
vcsStage: stage,
|
||||
vcsAddToIgnore: ignore,
|
||||
vcsStatus: async () => ({ status: "ok", data: [] }),
|
||||
vcsBranchInfo: async () => ({ status: "ok", data: null }),
|
||||
vcsRoots: async () => ({ status: "ok", data: [{ root: "/repo", operation: null }] }),
|
||||
},
|
||||
};
|
||||
});
|
||||
vi.mock("@/workbench/contributions", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/workbench/contributions")>()),
|
||||
projectViewSelection: () => project.paths,
|
||||
notifications: () => ({ notify }),
|
||||
}));
|
||||
vi.mock("../comparePaths", () => ({ showDirectoryWorkingDiff: async () => false }));
|
||||
vi.mock("../diffDialog", () => ({ openDiffDialog: vi.fn() }));
|
||||
vi.mock("../DiffWindow", () => ({ showDiffWindow: vi.fn() }));
|
||||
|
||||
import { getAction } from "@/platform/actions";
|
||||
import { registerVcsActions } from "../actions";
|
||||
import { useVcs } from "../store";
|
||||
|
||||
const fs = (relPath: string, unstaged: FileStatus["unstaged"]): FileStatus => ({
|
||||
path: `/repo/${relPath}`,
|
||||
relPath,
|
||||
staged: null,
|
||||
unstaged,
|
||||
renamedFrom: null,
|
||||
});
|
||||
|
||||
let unregister: () => void;
|
||||
|
||||
beforeEach(() => {
|
||||
stage.mockClear();
|
||||
ignore.mockClear();
|
||||
notify.mockClear();
|
||||
project.paths = [];
|
||||
const files = [fs("dir/new.ts", "untracked"), fs("dir/sub/n2.ts", "untracked"), fs("dir/tracked.ts", "modified")];
|
||||
useVcs.setState({
|
||||
root: "/repo",
|
||||
roots: ["/repo"],
|
||||
status: files,
|
||||
byPath: new Map(files.map((f) => [f.path, f])),
|
||||
statusLoaded: true,
|
||||
});
|
||||
unregister = registerVcsActions();
|
||||
});
|
||||
|
||||
afterEach(() => unregister());
|
||||
|
||||
const addToVcs = () => getAction("vcs.addToVcs")!;
|
||||
|
||||
describe("Add to VCS", () => {
|
||||
it("adds the unversioned files below the Project view's selected directory", async () => {
|
||||
project.paths = ["/repo/dir"];
|
||||
await addToVcs().run({ arg: undefined, ctx: { vcsAvailable: true, projectViewFocus: true } });
|
||||
expect(stage).toHaveBeenCalledWith(["/repo/dir/new.ts", "/repo/dir/sub/n2.ts"]);
|
||||
expect(notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("leaves the Project view's selection alone while another view has focus", async () => {
|
||||
project.paths = ["/repo/dir"];
|
||||
await addToVcs().run({ arg: undefined, ctx: { vcsAvailable: true } });
|
||||
expect(stage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("only adds the unversioned files under an explicit selection", async () => {
|
||||
await addToVcs().run({ arg: ["/repo/dir/tracked.ts"], ctx: { vcsAvailable: true } });
|
||||
expect(stage).not.toHaveBeenCalled();
|
||||
expect(notify).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ title: "Nothing to add: the files are already under version control" }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Add to .gitignore", () => {
|
||||
it("ignores the Project view's selection while it has focus, and not otherwise", async () => {
|
||||
project.paths = ["/repo/dir/new.ts"];
|
||||
await getAction("vcs.ignoreShared")!.run({ arg: undefined, ctx: { vcsAvailable: true, projectViewFocus: true } });
|
||||
expect(ignore).toHaveBeenCalledWith(["/repo/dir/new.ts"], "gitignore");
|
||||
ignore.mockClear();
|
||||
await getAction("vcs.ignoreShared")!.run({ arg: undefined, ctx: { vcsAvailable: true } });
|
||||
expect(ignore).not.toHaveBeenCalledWith(["/repo/dir/new.ts"], "gitignore");
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import type { Commit } from "@/bindings";
|
||||
|
||||
const { files, combined, executeAction } = vi.hoisted(() => ({
|
||||
@@ -69,8 +69,10 @@ describe("Push dialog changes", () => {
|
||||
const one = { ...older, message: "Add order service\n\nIntroduces the service.\n", timeMs: 1_700_000_000_000 };
|
||||
render(<PushChanges repo="/r" commits={[one]} />);
|
||||
const details = screen.getByRole("region", { name: "Commit details" });
|
||||
expect(details.textContent).toContain("Add order service\n\nIntroduces the service.");
|
||||
expect(details.textContent).toContain("aaaaaaa me <[email protected]> on ");
|
||||
const message = within(details);
|
||||
expect(message.getByText("Add order service", { exact: true })).toBeTruthy();
|
||||
expect(message.getByText("Introduces the service.", { exact: true })).toBeTruthy();
|
||||
expect(message.getByText(/^aaaaaaa me <me@example\.com> on /)).toBeTruthy();
|
||||
expect(await screen.findByText("src/orders")).toBeTruthy();
|
||||
expect(screen.getAllByRole("treeitem")).toHaveLength(2);
|
||||
const grouping = screen.getByRole("button", { name: "Group by Directory" });
|
||||
|
||||
@@ -156,6 +156,11 @@ function selectedPaths(arg: unknown): string[] {
|
||||
return project.length ? project : contextPaths(arg);
|
||||
}
|
||||
|
||||
/** Paths a file action targets: the Project view's selection while it has focus, else the open file. */
|
||||
function focusedPaths(arg: unknown, ctx: { projectViewFocus?: unknown }): string[] {
|
||||
return ctx.projectViewFocus ? selectedPaths(arg) : contextPaths(arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* The repository a repository-wide dialog (Pull, Merge, Rebase) starts on: the one holding the
|
||||
* action's file, else the Project view's selection while it has focus, else the active editor's
|
||||
@@ -661,8 +666,8 @@ export function registerVcsActions(): () => void {
|
||||
category: "Git",
|
||||
icon: "history",
|
||||
when: VCS,
|
||||
run: ({ arg }) => {
|
||||
const path = contextPaths(arg)[0];
|
||||
run: ({ arg, ctx }) => {
|
||||
const path = focusedPaths(arg, ctx)[0];
|
||||
if (!path) return;
|
||||
openLogTab("history", path);
|
||||
showGitWindow();
|
||||
@@ -717,7 +722,7 @@ export function registerVcsActions(): () => void {
|
||||
category: "Git",
|
||||
when: VCS,
|
||||
keywords: ["ignore", "unversioned", "exclude"],
|
||||
run: ({ arg }) => addToIgnore(contextPaths(arg), destination),
|
||||
run: ({ arg, ctx }) => addToIgnore(focusedPaths(arg, ctx), destination),
|
||||
})),
|
||||
{
|
||||
id: "vcs.addToVcs",
|
||||
@@ -726,9 +731,7 @@ export function registerVcsActions(): () => void {
|
||||
icon: "plus",
|
||||
when: VCS,
|
||||
keywords: ["git add", "stage"],
|
||||
run: ({ arg }) => {
|
||||
return addToVcs(contextPaths(arg));
|
||||
},
|
||||
run: ({ arg, ctx }) => addToVcs(focusedPaths(arg, ctx)),
|
||||
},
|
||||
{
|
||||
id: "vcs.stash",
|
||||
|
||||
@@ -363,9 +363,6 @@
|
||||
.pushCommitDetails {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
margin: var(--space-1) var(--space-3);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
overflow: auto;
|
||||
@@ -374,11 +371,6 @@
|
||||
-webkit-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
.pushCommitMessage {
|
||||
color: var(--fg-strong);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.todoList {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 18px;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import type { Commit } from "@/bindings";
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { fontWeightOf } from "@/platform/editorSettings";
|
||||
import { resolveMonoFont } from "@/platform/fonts";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import clsx from "clsx";
|
||||
import { CommitMessageContent } from "../CommitMessageContent";
|
||||
import styles from "../GitLog.module.css";
|
||||
import { IssueText } from "../issueLinks";
|
||||
import { useCommitDetails } from "../logDetails";
|
||||
@@ -37,7 +35,7 @@ export function RefLabels({
|
||||
}) {
|
||||
const labels = refLabels(refs, { compact, tagNames }, remoteNames);
|
||||
return (
|
||||
<span className={clsx(styles.refs, left && styles.refsLeft)}>
|
||||
<span className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}>
|
||||
{labels.map((l) => (
|
||||
<span key={`${l.kind}:${l.title}`} className={clsx(styles.ref, REF_KIND_CLASS[l.kind])} title={l.title}>
|
||||
{l.text && <span className={styles.refText}>{l.text}</span>}
|
||||
@@ -50,39 +48,25 @@ export function RefLabels({
|
||||
/** A commit's message and metadata; `compact` (one of several selected): without the body. */
|
||||
export function CommitMessage({ commit, compact = false }: { commit: Commit; compact?: boolean }) {
|
||||
const { details, error } = useCommitDetails(commit, !compact);
|
||||
const editor = useProject((s) => s.settings?.editor);
|
||||
const { family, size } = resolveMonoFont(undefined, editor);
|
||||
const repo = commitRepo(commit) ?? currentRepo();
|
||||
const message = details?.message || commit.message;
|
||||
const [subject, ...bodyLines] = message.replace(/\s+$/, "").split("\n");
|
||||
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
|
||||
return (
|
||||
<div className={clsx(compact && styles.commitEntry)}>
|
||||
<div
|
||||
className={styles.messageText}
|
||||
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
|
||||
>
|
||||
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
|
||||
<CommitMessageText text={subject ?? ""} repo={repo} />
|
||||
</div>
|
||||
{body && (
|
||||
<div className={styles.fullMessage}>
|
||||
<CommitMessageText text={body} repo={repo} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.meta}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.linkButton}
|
||||
title={tx("Copy revision number")}
|
||||
onClick={() => void writeClipboardText(commit.id)}
|
||||
>
|
||||
{commit.shortId}
|
||||
</button>{" "}
|
||||
{commit.author} <{commit.email}>
|
||||
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
|
||||
</div>
|
||||
<CommitMessageContent
|
||||
commit={commit}
|
||||
message={details?.message || commit.message}
|
||||
compact={compact}
|
||||
renderText={(text) => <CommitMessageText text={text} repo={repo} />}
|
||||
revision={
|
||||
<button
|
||||
type="button"
|
||||
className={styles.linkButton}
|
||||
title={tx("Copy revision number")}
|
||||
onClick={() => void writeClipboardText(commit.id)}
|
||||
>
|
||||
{commit.shortId}
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
{!compact &&
|
||||
commit.committer &&
|
||||
(commit.committer !== commit.author ||
|
||||
|
||||
@@ -134,7 +134,9 @@ function CommitRowView({
|
||||
setTooltip(false);
|
||||
}}
|
||||
>
|
||||
<IssueText text={c.summary} />
|
||||
<span className={styles.subjectText}>
|
||||
<IssueText text={c.summary} />
|
||||
</span>
|
||||
</span>
|
||||
{!opts.refsOnLeft && refs}
|
||||
</span>
|
||||
|
||||
@@ -502,7 +502,6 @@
|
||||
"Unknown error": "Unknown error",
|
||||
"Retry Loading Conversation": "Retry Loading Conversation",
|
||||
"No conversation history": "No conversation history",
|
||||
"No history": "No history",
|
||||
"Loading the conversation timed out. Try again.": "Loading the conversation timed out. Try again.",
|
||||
"Couldn't load the conversation: {0}": "Couldn't load the conversation: {0}",
|
||||
"Astro Language Server": "Astro Language Server",
|
||||
|
||||
@@ -785,6 +785,7 @@
|
||||
"Evaluate": "Evaluar",
|
||||
"Evaluate Expression…": "Evaluar expresión…",
|
||||
"Evaluate expression": "Evaluar expresión",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Evaluar expresión (↩) o agregar una expresión de inspección (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "Evaluar en la consola de depuración",
|
||||
"Evaluation result": "Resultado de la evaluación",
|
||||
"Everything is up to date": "Todo está actualizado",
|
||||
|
||||
@@ -722,6 +722,7 @@
|
||||
"Evaluate": "Évaluer",
|
||||
"Evaluate Expression…": "Évaluer l'expression…",
|
||||
"Evaluate expression": "Évaluer l'expression",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Évaluer l'expression (↩) ou ajouter une expression surveillée (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "Évaluer dans la console de débogage",
|
||||
"Evaluation result": "Résultat de l'évaluation",
|
||||
"Everything is up to date": "Tout est à jour",
|
||||
|
||||
@@ -821,6 +821,7 @@
|
||||
"Evaluate": "평가",
|
||||
"Evaluate Expression…": "표현식 평가…",
|
||||
"Evaluate expression": "표현식 평가",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "표현식 평가(↩) 또는 watch 추가(⇧⌘↩)",
|
||||
"Evaluate in the debug console": "디버그 콘솔에서 평가",
|
||||
"Evaluation result": "평가 결과",
|
||||
"Everything is up to date": "모두 최신 상태입니다",
|
||||
|
||||
@@ -777,6 +777,7 @@
|
||||
"Evaluate": "Oblicz/Ewaluuj",
|
||||
"Evaluate Expression…": "Oblicz wyrażenie…",
|
||||
"Evaluate expression": "Oblicz wyrażenie",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Oblicz wyrażenie (↩) lub dodaj do obserwowanych (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "Oblicz w konsoli debugowania",
|
||||
"Evaluation result": "Wynik obliczenia",
|
||||
"Everything is up to date": "Wszystko jest aktualne",
|
||||
|
||||
@@ -777,6 +777,7 @@
|
||||
"Evaluate": "Avaliar",
|
||||
"Evaluate Expression…": "Avaliar expressão…",
|
||||
"Evaluate expression": "Avaliar expressão",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "Avaliar expressão (↩) ou adicionar inspeção (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "Avaliar no console de depuração",
|
||||
"Evaluation result": "Resultado da avaliação",
|
||||
"Everything is up to date": "Tudo está atualizado",
|
||||
|
||||
@@ -3575,6 +3575,7 @@
|
||||
"Evaluate": "Değerlendir",
|
||||
"Evaluate Expression…": "İfadeyi Değerlendir…",
|
||||
"Evaluate expression": "İfadeyi değerlendir",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "İfadeyi değerlendir (↩) veya izleme ekle (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "Hata ayıklama konsolunda değerlendir",
|
||||
"Evaluation result": "Değerlendirme sonucu",
|
||||
"Everything is up to date": "Her şey güncel",
|
||||
|
||||
@@ -1441,6 +1441,7 @@
|
||||
"Evaluate": "計算",
|
||||
"Evaluate Expression…": "計算表示式…",
|
||||
"Evaluate expression": "計算表示式",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "計算表示式 (↩) 或新增監視 (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "在偵錯主控台中計算",
|
||||
"Evaluation result": "計算結果",
|
||||
"Everything is up to date": "一切都是最新的",
|
||||
|
||||
@@ -1485,6 +1485,7 @@
|
||||
"Evaluate": "计算",
|
||||
"Evaluate Expression…": "计算表达式…",
|
||||
"Evaluate expression": "计算表达式",
|
||||
"Evaluate expression (↩) or add a watch (⇧⌘↩)": "计算表达式 (↩) 或添加监视 (⇧⌘↩)",
|
||||
"Evaluate in the debug console": "在调试控制台中计算",
|
||||
"Evaluation result": "计算结果",
|
||||
"Everything is up to date": "一切都是最新的",
|
||||
|
||||
Reference in new issue
Block a user