Compare commits

..
Author SHA1 Message Date
l0ng-ai 679c905621 fix(vcs): keep Git Log path selection in a resizable tree 2026-11-22 20:57:10 +08:00
52 changed files with 604 additions and 1473 deletions

No files matched your search

+3 -12
View File
@@ -18,27 +18,18 @@ 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 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();
await dialog.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check();
await dialog.getByRole("textbox", { name: "Evaluate and log", exact: true }).fill("total: {amount}");
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(log).toHaveValue("total: {amount}");
await expect(temporary).toBeChecked();
await expect(dialog.getByRole("textbox", { name: "Evaluate and log", exact: true })).toHaveValue("total: {amount}");
await page.setViewportSize({ width: 1080, height: 760 });
const divider = dialog.locator('[data-separator][aria-orientation="vertical"]');
-52
View File
@@ -715,58 +715,6 @@ 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);
+34 -151
View File
@@ -4,178 +4,61 @@ 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.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 });
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1220, height: 760 });
await stubDesktop(page);
await page.evaluate(
async ({ name, type, value, countName }) => {
async ({ amountName, routingName, routingValue }) => {
const debugModule = "/src/features/debugger/state.ts";
const layoutModule = "/src/workbench/toolwindows/store.ts";
const serviceModule = "/src/workbench/contributions.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 */ 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 },
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 },
];
adoptSession(92, {
name: "Settlement",
adoptSession(91, {
name: "Checkout",
adapter: "debugpy",
status: "paused",
selectedFrame: 11,
frames: [{ id: 11, name: "settle", path: null, line: 0, column: 0, presentationHint: null }],
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
});
moveToolWindow("debug", "right");
setToolWindowSize("right", 280);
setToolWindowSize("right", 390);
toolWindowService().show("debug", true);
},
{ name, type, value, countName },
{ amountName, routingName, routingValue },
);
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
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();
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 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.setViewportSize({ width: 1640, height: 760 });
await page.evaluate(async () => {
const layoutModule = "/src/workbench/toolwindows/store.ts";
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
moveToolWindow("debug", "bottom");
setToolWindowSize("bottom", 310);
});
await expect.poll(() => annotation.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect(show).toBeHidden();
await expect
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
.toBe(true);
});
+1 -65
View File
@@ -1,6 +1,6 @@
import type { EditorView } from "@codemirror/view";
import type { Page } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
import { expect, test } from "./fixtures";
async function openChain(page: Page) {
await page.evaluate(async () => {
@@ -46,70 +46,6 @@ 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 () => {
-46
View File
@@ -69,49 +69,3 @@ 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");
});
+2 -2
View File
@@ -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 expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
test("keeps 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 expanded ref names visible when a long commit subject competes for s
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, compactRefs: false });
useLogOptions.setState({ tagNames: true });
const [first, ...rest] = useGitLog.getState().commits;
useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] });
},
+85 -51
View File
@@ -112,57 +112,6 @@ 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" });
@@ -371,3 +320,88 @@ test("the Paths filter replaces the repository filter and can be cleared from ov
await picker.getByRole("button", { name: "OK" }).click();
await expect(firstCommit.getByText("Commit 1", { exact: true })).toBeVisible();
});
test("the Git Log path tree resizes and keeps selected paths reachable in a short window", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 1000, height: 720 });
const longName = "reconcile-invoices-and-export-the-complete-quarterly-settlement-audit.ts";
await page.evaluate(async (longName) => {
const logPath = "/src/features/vcs/logStore.ts";
const optionsPath = "/src/features/vcs/logOptions.ts";
const { setLogFilters } = await import(/* @vite-ignore */ logPath);
const { setLogOptions } = await import(/* @vite-ignore */ optionsPath);
const root = "/dev/acme-api";
const selected = Array.from({ length: 9 }, (_, i) => `entry-${i + 1}.ts`);
const entry = (name: string, kind: "dir" | "file") => ({
name,
path: `${root}/${name}`,
kind,
size: 0,
mtimeMs: 0,
});
window.__ipc.handlers.fs_read_dir = ({ path }) =>
path === root
? [entry("src", "dir"), entry(longName, "file"), ...selected.map((name) => entry(name, "file"))]
: [];
setLogOptions({ showBranches: false, showDetails: false });
setLogFilters({ paths: selected.map((name) => `${root}/${name}`) });
}, longName);
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
const openTree = async () => {
await toolbar.getByRole("button", { name: "More Filters" }).click();
await page.getByRole("menuitem", { name: /^Paths:/ }).click();
await page.getByRole("menuitem", { name: "Select in Tree…" }).click();
};
await openTree();
const dialog = page.getByRole("dialog", { name: "Filter by Paths" });
const tree = dialog.getByRole("tree", { name: "Files and folders" });
const resize = dialog.locator('[class*="_resizeGrip_"]');
await expect(tree).toBeVisible();
await expect(resize).toBeVisible();
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
const folder = tree.getByRole("checkbox", { name: "src", exact: true });
const file = tree.getByRole("checkbox", { name: longName, exact: true });
await expect(folder.locator("xpath=ancestor::label").locator("svg")).toHaveCount(1);
const title = file.locator("xpath=ancestor::label").getByTitle(longName);
await expect(title).toHaveCSS("font-size", "13px");
await expect(title).toHaveCSS("text-overflow", "ellipsis");
const originalTreeHeight = (await tree.boundingBox())!.height;
const grip = (await resize.boundingBox())!;
const x = grip.x + grip.width / 2;
const y = grip.y + grip.height / 2;
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + 30, y + 65, { steps: 5 });
await page.mouse.up();
await expect.poll(async () => (await tree.boundingBox())!.height).toBeGreaterThan(originalTreeHeight + 40);
await dialog.getByRole("button", { name: "Cancel" }).click();
await page.setViewportSize({ width: 420, height: 325 });
await openTree();
await tree.getByRole("treeitem", { name: "acme-api", exact: true }).locator("[data-tree-toggle]").click();
const selected = dialog.getByRole("group", { name: "Selected paths" });
await expect(selected).toBeVisible();
await expect.poll(() => selected.evaluate((node) => node.scrollHeight - node.clientHeight)).toBeGreaterThan(1);
await expect
.poll(() => dialog.locator("[data-dialog-body]").evaluate((node) => node.scrollHeight - node.clientHeight))
.toBeLessThanOrEqual(1);
await expect.poll(() => title.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeGreaterThan(1);
const removed = selected.getByRole("checkbox", { name: "acme-api/entry-9.ts", exact: true });
await removed.click();
await expect(removed).toHaveCount(0);
await file.check();
await expect(selected.getByRole("checkbox", { name: `acme-api/${longName}`, exact: true })).toBeChecked();
await expect(dialog.getByRole("button", { name: "OK" })).toBeInViewport({ ratio: 1 });
await dialog.getByRole("button", { name: "OK" }).click();
await expect(dialog).toBeHidden();
const applied = await page.evaluate(async () => {
const path = "/src/features/vcs/logStore.ts";
const { useGitLog } = await import(/* @vite-ignore */ path);
return useGitLog.getState().filters.paths;
});
expect(applied).toContain(`/dev/acme-api/${longName}`);
expect(applied).not.toContain("/dev/acme-api/entry-9.ts");
});
+1 -23
View File
@@ -176,29 +176,7 @@ 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 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(details).toContainText("Keep the new totals consistent with receipts.");
await expect
.poll(async () => {
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
-39
View File
@@ -93,42 +93,3 @@ 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();");
});
-63
View File
@@ -1,63 +0,0 @@
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
View File
@@ -76,73 +76,6 @@ 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");
@@ -189,45 +122,6 @@ 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…";
@@ -390,64 +284,6 @@ 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 -8
View File
@@ -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 name visible while scrolling at ${height}px`, async ({
test(`run configurations dialog keeps its toolbar and scrolls only inside the panes at ${height}px`, async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 900, height });
@@ -62,13 +62,9 @@ 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*="_formSettings_"]');
const nameField = dialog.getByRole("textbox", { name: "Name", exact: true });
const form = dialog.locator('[class*="_editForm_"]');
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);
@@ -78,8 +74,6 @@ 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,
+3 -3
View File
@@ -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*='_formSettings_']").evaluate((el) => el.scrollHeight - el.clientHeight))
.poll(() => dialog.locator("[class*='editForm_']").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*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
.poll(() => dialog.locator("[class*='editForm_']").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*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth))
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth))
.toBeLessThanOrEqual(1);
const tasks = dialog.getByRole("list");
await tasks.scrollIntoViewIfNeeded();
+6 -18
View File
@@ -5,8 +5,6 @@
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";
@@ -17,16 +15,15 @@ async function run(page: Page, id: string) {
async function stubFindMatches(page: Page) {
await stubDesktop(page);
await page.evaluate((longPath) => {
await page.evaluate(() => {
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 = 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 }));
const relPath = `config/endpoint-${i}.txt`;
const matches = [{ line: 0, text, ranges: [[5, text.length]], textOffset: 0 }];
send({
type: "file",
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
@@ -34,12 +31,12 @@ async function stubFindMatches(page: Page) {
}
send({
type: "done",
summary: { files: 12, matches: 13, limitHit: false, cancelled: false, elapsedMs: 4 },
summary: { files: 12, matches: 12, limitHit: false, cancelled: false, elapsedMs: 4 },
});
}, 20);
return null;
};
}, LONG_RESULT_PATH);
});
}
async function expectControlsFit(page: Page) {
@@ -77,8 +74,7 @@ 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("13 matches in 12 files", { exact: true });
const line = dialog.getByText("12345", { exact: true });
const count = dialog.getByText("12 matches in 12 files", { exact: true });
for (const [width, height] of [
[400, 500],
[600, 700],
@@ -91,14 +87,6 @@ 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 });
}
-33
View File
@@ -1,38 +1,5 @@
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();
-45
View File
@@ -1,45 +0,0 @@
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);
});
-1
View File
@@ -40,7 +40,6 @@ 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,
-6
View File
@@ -26,12 +26,6 @@ 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);
});
+20 -19
View File
@@ -1,6 +1,6 @@
/**
* Directory hints for files that share a name: a distinguishing parent
* directory is shown after the name (`lib.rs — ide-lsp`
* 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`
* for `crates/ide-lsp/src/lib.rs` next to `crates/ide-vcs/src/lib.rs`).
*/
@@ -27,24 +27,25 @@ 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 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) ?? "/");
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("/") : "/"));
});
}
return out;
@@ -150,28 +150,6 @@
.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;
+2 -10
View File
@@ -219,23 +219,15 @@ 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: 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>
) : (
label: (
<>
{file?.deprecated ? <span className={styles.deprecated}>{title}</span> : title}
{dupe && <span className={styles.dupe}>{dupe}</span>}
</>
),
text: prefix ? `${prefix}${name}` : dupe ? `${name} — ${dupe}` : name,
text: dupe ? `${name} — ${dupe}` : name,
icon: showFileIcon
? t.input.kind === "file" && t.input.path
? (tabIcons[i] ?? file?.icon)
+18 -27
View File
@@ -532,6 +532,20 @@
.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;
}
@@ -557,46 +571,23 @@
padding: 0 14px;
font-size: var(--fs-ui);
}
.previewFile {
flex: 1 1 auto;
display: flex;
align-items: baseline;
gap: var(--space-2);
min-width: 0;
.previewName {
color: var(--fg-emphasis);
}
.previewName,
.previewDirectory,
.previewOp {
.previewPath {
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;
+1 -26
View File
@@ -15,7 +15,7 @@ vi.mock("@/workbench/contributions", async (orig) => {
});
const { LspPopups, DocumentationWindow } = await import("./Popups");
const { closePopup, openPopup, updatePopup, useLspPopup } = await import("./popupStore");
const { closePopup, openPopup, useLspPopup } = await import("./popupStore");
const { useDocWindow, hoverDoc, pushHistory, stepHistory, hoverCandidates } = await import("./docs");
const { mountHoverDoc } = await import("./DocView");
const { hoverSource } = await import("./hover");
@@ -139,31 +139,6 @@ 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",
+29 -37
View File
@@ -22,7 +22,7 @@ import {
selectableText,
T,
} from "@/ui";
import { basename, relativeDir, relativePath, useProject } from "@/platform/project";
import { basename, relativePath, useProject } from "@/platform/project";
import {
closePopup,
updatePopup,
@@ -112,10 +112,14 @@ 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 [activeId, setActiveId] = useState<string | null>(null);
const selected = rows.findIndex((row) => row.kind === "action" && row.item.id === activeId);
const [active, setActive] = useState(firstEnabled);
const clamped = Math.min(active, rows.length - 1);
const activeIndex =
selected >= 0 ? selected : firstEnabled >= 0 ? firstEnabled : firstSelectable(rows, isListSection);
rows[clamped]?.kind === "action"
? clamped
: 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);
@@ -179,11 +183,11 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
if (item) activate(item);
} else if (e.key === "Backspace" && query) {
setQuery(query.slice(0, -1));
setActiveId(null);
setActive(-1);
e.preventDefault();
} else if (e.key.length === 1 && !(e.key === " " && !query)) {
setQuery(query + e.key);
setActiveId(null);
setActive(-1);
e.preventDefault();
}
};
@@ -293,10 +297,7 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
row.kind === "section" && row.label ? <T>{row.label}</T> : <span className={styles.listDivider} />
}
activeIndex={activeIndex}
onActiveChange={(index) => {
const row = rows[index];
setActiveId(row?.kind === "action" ? row.item.id : null);
}}
onActiveChange={setActive}
hoverSelects
autoFocus
aria-label={popup.title}
@@ -761,34 +762,25 @@ 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) => {
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>
)}
{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"}
</span>
{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>
);
})}
)}
</li>
))}
</ul>
)}
</Dialog>
+2 -10
View File
@@ -60,18 +60,11 @@ 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 are grouped separately from other actions. */
/** Local and language-server fixes share icons and the same stable ordering. */
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) => {
const fix = isFixItem(item);
return {
...item,
...(fix && { quickFix: true, icon: quickFixIcon(view) }),
section: item.section ?? { id: item.disabled ? "unavailable" : fix ? "quick-fixes" : "intentions" },
};
})
.map((item) => (isFixItem(item) ? { ...item, quickFix: true, icon: quickFixIcon(view) } : item))
.sort((a, b) => rank(a) - rank(b));
}
@@ -504,7 +497,6 @@ 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,16 +94,10 @@
flex: none;
color: var(--fg-muted);
}
.fileName,
.directory {
min-width: 0;
.fileName {
overflow: hidden;
text-overflow: ellipsis;
}
.directory {
flex: 0 2 auto;
color: var(--fg-subtle);
}
.line {
overflow: hidden;
text-align: right;
+5 -12
View File
@@ -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, disambiguateTitles } from "@/editor/api";
import { codePreviewExtensions } 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,14 +86,6 @@ 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(
@@ -241,10 +233,11 @@ function UsagesPopupInner() {
}
renderItem={(u) => (
<div className={styles.row} data-testid="usage-row" data-path={u.path} data-line={u.line}>
<span className={styles.file} title={u.path}>
<span className={styles.file}>
<Icon name={fileIconName(basename(u.path), u.path)} size={16} className={styles.icon} />
<span className={styles.fileName}>{basename(u.path)}</span>
{directories.has(u.path) && <span className={styles.directory}>{directories.get(u.path)}</span>}
<span className={styles.fileName} title={u.path}>
{basename(u.path)}
</span>
</span>
<span className={styles.line}>{u.line + 1}</span>
<UsagePreview usage={u} />
+1 -18
View File
@@ -29,23 +29,6 @@
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;
@@ -229,7 +212,7 @@
font-family: var(--font-ui);
}
:is(.detail, .bpEditor) .label {
.detail .label {
font-size: var(--fs-ui);
}
+31 -40
View File
@@ -212,14 +212,12 @@ 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 ?? "");
@@ -310,44 +308,32 @@ function BreakpointFields({
aria-label="Hit count condition"
/>
</label>
<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={!!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"
/>
<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>
)}
</>
);
}
@@ -785,7 +771,12 @@ 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} showRemoveOnceHit />
<BreakpointFields path={path} bp={bp} commitRef={commitRef} />
<Checkbox
checked={!!bp.temporary}
onChange={(temporary) => updateBreakpoint(path, bp.id, { temporary })}
label="Remove once hit"
/>
</div>
);
}
@@ -55,8 +55,7 @@
display: flex;
align-items: center;
gap: var(--space-1);
/* Cap the automatic flex minimum at the space needed for a short preview. */
width: min(14ch, 50%);
min-width: min(8ch, 45%);
flex: 1 1 0;
}
@@ -136,8 +135,9 @@
}
.type {
min-width: min(3ch, 10%);
flex: 0 4 auto;
min-width: 0;
max-width: 25%;
flex: 0 1 auto;
overflow: hidden;
text-overflow: ellipsis;
color: var(--fg-subtle);
@@ -159,17 +159,11 @@
font-size: var(--fs-ui);
}
.editRow,
.editRow > .valueGroup {
height: 100%;
}
.editInput {
box-sizing: border-box;
flex: 1 1 0;
min-width: 0;
height: calc(100% - var(--space-1));
padding: 0 var(--space-1);
flex: 1;
min-width: min(80px, 40%);
height: 18px;
padding: 0 4px;
font: inherit;
font-family: var(--font-mono);
color: var(--fg-strong);
@@ -182,10 +176,6 @@
border-color: var(--danger);
}
.editError {
max-width: 33%;
}
/* Changed since the previous stop. */
.name.changed {
color: var(--debug-changed, var(--link));
+48 -58
View File
@@ -467,7 +467,6 @@ 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 })}
@@ -559,7 +558,6 @@ function ValueDialog({
function VarEditRow({
node,
changed,
value,
error,
onChange,
@@ -567,7 +565,6 @@ function VarEditRow({
onCancel,
}: {
node: VarNode;
changed: boolean;
value: string;
error: string | null;
onChange: (v: string) => void;
@@ -578,36 +575,37 @@ function VarEditRow({
// the global "Escape → focus editor" binding (`!popupOpen`) from firing.
useEffect(() => acquirePopup(), []);
return (
<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 className={styles.row}>
<span className={styles.name} title={node.name}>
{node.name}
</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>
);
}
@@ -618,31 +616,6 @@ 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,
@@ -682,9 +655,26 @@ 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}>
<VarPrefix node={node} changed={changed} showName={!shown.entry} />
<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>
</>
)}
{node.error ? (
<span className={styles.error}>{oneLine(node.error)}</span>
) : (
+2 -2
View File
@@ -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>
);
+6 -15
View File
@@ -143,10 +143,7 @@ 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: "line", index: i, fold });
i++;
} else rows.push({ kind: "fold", fold });
else if (!fold.expanded) rows.push({ kind: "fold", fold });
if (fold.expanded) for (; i < j; i++) rows.push({ kind: "line", index: i });
i = j;
continue;
@@ -233,7 +230,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" && lines[lastRow.index] === model.openLine;
!!input && !!model.openLine && lastRow?.kind === "line" && !lastRow.fold && 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`
@@ -258,7 +255,7 @@ export function ConsoleView({
getItemKey: (i) => {
const r = rows[i];
if (!r) return "input";
return r.kind === "fold" ? r.fold.id : (lines[r.index]?.id ?? i);
return r.kind === "fold" ? `f${r.fold.id}` : (lines[r.index]?.id ?? i);
},
});
@@ -489,7 +486,7 @@ export function ConsoleView({
return;
}
if (copySelectionOnKeyDown(e, selectedOutput)) return;
if (!input || e.target instanceof HTMLButtonElement) return;
if (!input) return;
if (e.key === "d" && e.ctrlKey && !e.metaKey && !e.altKey) {
e.preventDefault();
input.onEof();
@@ -526,24 +523,19 @@ 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-down" size={10} />
<Icon name="chevron-up" 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>`}`}
@@ -659,7 +651,6 @@ 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)}
@@ -667,7 +658,7 @@ export function ConsoleView({
length={line.text.length}
cwd={cwd}
/>
{row.fold && !row.fold.expanded && foldButton(row.fold, true)}
{row.fold && foldButton(row.fold, true)}
{inputInline && item.index === rows.length - 1 && pendingInput}
{"\n"}
</div>
+22 -51
View File
@@ -212,7 +212,7 @@
top: 0;
left: 0;
min-width: 100%;
padding: 0 var(--space-3);
padding: 0 12px;
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,36 +275,27 @@
border-inline-end: 1px solid var(--border);
}
.testStatusBar {
gap: var(--space-2);
gap: var(--space-0-5) 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 {
.testStatus,
.testTotalDuration {
flex: none;
}
.testTotalDuration {
margin-left: auto;
color: var(--fg-subtle);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.testTree {
@@ -674,39 +665,22 @@
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 > *,
.formSettings > * {
.configFields > * {
grid-column: 1 / -1;
min-width: 0;
}
.configFields > .notice {
grid-row: notice;
}
.configFields:not(.configFieldsTomcat) > .notice,
.configFields:not(.configFieldsTomcat) > .formHeader {
margin-bottom: var(--space-2);
}
.configFields:not(.configFieldsTomcat) > .field,
.configFields:not(.configFieldsTomcat) > .formHeader,
.configFields:not(.configFieldsTomcat) > .formHeader > .field,
.formSettings > .field {
.configFields:not(.configFieldsTomcat) > .formHeader > .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;
}
@@ -714,6 +688,8 @@
overflow: hidden;
}
.configFieldsTomcat {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
gap: var(--space-2);
@@ -817,7 +793,6 @@
}
.formHeader {
display: grid;
grid-row: header;
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: var(--space-4);
@@ -1143,19 +1118,15 @@
color: var(--fg);
}
.foldToggle {
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;
display: inline-flex;
align-items: center;
margin-left: 6px;
padding: 0 2px;
border: none;
border-radius: var(--radius-small);
background: var(--bg-app);
border-radius: 3px;
background: none;
color: var(--fg-faint);
vertical-align: top;
vertical-align: middle;
cursor: pointer;
}
.foldToggle:hover {
+25 -68
View File
@@ -9,7 +9,6 @@ import {
Icon,
IconButton,
Menu,
type MenuItem,
SplitGroup,
SplitHandle,
SplitPanel,
@@ -101,33 +100,21 @@ 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 (!hasRuntime || !pane || (!showLifecycle && !hasTests)) return;
const measure = () => {
const width = pane.clientWidth;
if (showLifecycle) setCompactToolbar(width < fullToolbarWidth);
if (hasTests) setStackedTests(width < 560);
};
if (!hasTests || !pane) return;
const measure = () => setStackedTests(pane.clientWidth < 560);
measure();
if (typeof ResizeObserver === "undefined") return;
const resize = new ResizeObserver(measure);
resize.observe(pane);
return () => resize.disconnect();
}, [hasRuntime, hasTests, showLifecycle, fullToolbarWidth]);
}, [hasTests]);
useLayoutEffect(() => {
if (hasTests) testSplit.current?.setLayout(testLayouts.current[testOrientation]);
}, [hasTests, testOrientation]);
@@ -170,24 +157,7 @@ export function SessionPanel({
}, [selectedTest, rt, version]); // eslint-disable-line react-hooks/exhaustive-deps
if (!rt) return null;
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 toggleWrap = () => setWrapOverride(!softWrap);
const consoleColumn = (
<div className={styles.consoleColumn}>
@@ -253,7 +223,6 @@ 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"
@@ -271,7 +240,14 @@ export function SessionPanel({
onClick={() => void rerunFailed(session.id)}
/>
)}
{canUpdateApplication && (
<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) && (
<IconButton
icon="refresh"
title="Update Application"
@@ -280,9 +256,8 @@ export function SessionPanel({
onClick={() => showApplicationUpdate(session.id)}
/>
)}
{hasFlutterActions && (
{supportsHotReload(session.config) && (
<>
{stopButton}
<IconButton
icon="hot-reload"
title="Hot Reload"
@@ -311,41 +286,23 @@ export function SessionPanel({
pressed={findOpen}
onClick={() => setFindOpen((v) => !v)}
/>
{!overflowConsoleToggles &&
consoleToggles.map(({ label, icon, checked, run }) => (
<IconButton key={label} icon={icon} title={label} pressed={checked} onClick={run} />
))}
<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} />
</>
)}
<IconButton icon="trash" title="Clear All" onClick={() => clearConsole(session.id)} />
</div>
<div className={styles.toolbarGroup}>
{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)}
/>
)}
<IconButton
icon="settings"
title="Edit Configurations…"
onClick={() => void executeAction("run.editConfigs", session.config.id)}
/>
</div>
</div>
<div ref={body} className={styles.sessionBody}>
+13 -10
View File
@@ -112,24 +112,27 @@ export function TestStatusBar({
running: boolean;
}) {
const counts = useMemo(() => results.counts(), [results, version]); // eslint-disable-line react-hooks/exhaustive-deps
const outcome = counts.failed ? "failed" : counts.passed ? "passed" : counts.skipped ? "skipped" : null;
const status = running
? "running"
: counts.failed
? "failed"
: counts.passed
? "passed"
: counts.skipped
? "skipped"
: null;
const duration = results.summary.durationMs;
return (
<div
className={styles.testStatusBar}
role="status"
data-running={running || undefined}
data-outcome={outcome ?? undefined}
>
<StatusIcon status={running ? "running" : outcome} />
<div className={styles.testStatusBar} role="status">
<StatusIcon status={status} />
<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>}
{!outcome && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
{counts.total === 0 && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
</span>
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
</div>
);
}
@@ -162,8 +162,8 @@
}
.outdated .rowText,
.outdated .rowText *,
.outdated .rowLocation,
.outdated .rowLocation * {
.outdated .rowFile,
.outdated .rowFile * {
color: var(--fg-faint);
}
.rowText {
@@ -174,28 +174,18 @@
font-family: var(--font-mono);
font-weight: var(--fw-code);
}
.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;
flex: none;
max-width: 40%;
overflow: hidden;
text-overflow: ellipsis;
color: var(--fg-subtle);
}
.rowFileRepeated {
.rowFileActive {
color: var(--fg-muted);
}
.rowLine {
flex: none;
color: var(--fg-faint);
font-variant-numeric: tabular-nums;
}
.previewHeader {
+7 -15
View File
@@ -611,7 +611,6 @@ 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
@@ -627,20 +626,13 @@ function FindInFilesDialog() {
source={{ path: r.path, line: r.line, col: r.textCol }}
/>
</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 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>
</>
);
+26 -33
View File
@@ -15,7 +15,6 @@ 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,
@@ -41,7 +40,7 @@ import {
type ToolWindowContribution,
} from "@/workbench/contributions";
import { highlightTokens, languageForPath, type CodeToken } from "@/editor/lsp/markdown";
import { basename, openInListOrder, openLocation, relDir } from "../common/open";
import { basename, openInListOrder, openLocation } from "../common/open";
import { outlinePathAt } from "../structure/outline";
import { fromNavigationHistory, isDismissed, mergeLocations, type RecentLocation } from "../common/locations";
import { dismissLocation, useTracking } from "../common/tracking";
@@ -689,39 +688,33 @@ function RecentLocationsDialog() {
rowHeight={rowHeight}
aria-label="Recent locations"
empty={<span>{changedOnly ? tx("No changed locations") : tx("No recent locations")}</span>}
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}
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"
/>
<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,28 +101,19 @@
color: var(--fg-strong);
font-weight: 600;
}
.parentCrumbs {
display: flex;
.crumb:last-child {
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 {
flex: none;
margin-inline: var(--space-1);
margin: 0 4px;
color: var(--fg-subtle);
}
.reset {
@@ -165,29 +165,21 @@ 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")} 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>
))}
<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>
</span>
)}
<span className={clsx(styles.crumbLabel, styles.currentCrumb)} aria-current="page">
<T>{node.title}</T>
</span>
))}
</div>
<div ref={setHeaderSlot} className={styles.headerSlot} />
{dirty && (
-43
View File
@@ -1,43 +0,0 @@
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} &lt;{commit.email}&gt;
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
</div>
</>
);
}
-16
View File
@@ -118,22 +118,6 @@
.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);
+8 -25
View File
@@ -111,23 +111,6 @@ 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;
@@ -1388,7 +1371,7 @@ export function DiffEditor({
const canStage = editableB && isWorktree(right) && left.type === "rev" && !!useVcs.getState().root;
const hasSource = !!source;
const paneTitle = (s: DiffSide): PaneTitle => {
const paneTitle = (s: DiffSide): { label: string; detail?: string } => {
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;
@@ -1396,13 +1379,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),
revisionPath: root && file.startsWith(`${root}/`) ? file.slice(root.length + 1) : file,
detail: root && file.startsWith(`${root}/`) ? file.slice(root.length + 1) : file,
};
};
const titleA = paneTitle(left);
const titleB = paneTitle(right);
const captionA = [titleA.label, titleA.revisionPath ?? titleA.detail].filter(Boolean).join(" ");
const captionB = [titleB.label, titleB.revisionPath ?? titleB.detail].filter(Boolean).join(" ");
const captionA = [titleA.label, titleA.detail].filter(Boolean).join(" ");
const captionB = [titleB.label, titleB.detail].filter(Boolean).join(" ");
const sourceLabels = "labelDetail" in left || "labelDetail" in right;
const labels = clsx(styles.labels, sourceLabels && styles.sourceLabels);
@@ -1608,7 +1591,7 @@ export function DiffEditor({
<div className={labels}>
<span className={styles.label} title={captionA}>
<span className={styles.labelText}>{titleA.label}</span>
<PaneTitleDetail {...titleA} />
{titleA.detail && <span className={styles.labelFile}>{titleA.detail}</span>}
{eolDiffers && eolA && <span className={styles.badge}>{badgeA}</span>}
{editableA && (
<span className={styles.badge}>
@@ -1618,7 +1601,7 @@ export function DiffEditor({
</span>
<span className={styles.label} title={captionB}>
<span className={styles.labelText}>{titleB.label}</span>
<PaneTitleDetail {...titleB} />
{titleB.detail && <span className={styles.labelFile}>{titleB.detail}</span>}
{eolDiffers && eolB && <span className={styles.badge}>{badgeB}</span>}
{editableB && (
<span className={styles.badge}>{left.type === "rev" ? tx("working copy") : tx("editable")}</span>
@@ -1629,10 +1612,10 @@ export function DiffEditor({
<div className={labels}>
<span className={styles.label} title={sourceLabels ? `${captionA} → ${captionB}` : undefined}>
<span className={styles.labelText}>{sideLabel(left)}</span>
{sourceLabels && <PaneTitleDetail {...titleA} />}
{sourceLabels && titleA.detail && <span className={styles.labelFile}>{titleA.detail}</span>}
{eolDiffers && eolA && <span className={styles.badge}>{badgeA}</span>} →
<span className={styles.labelText}>{sideLabel(right)}</span>
{sourceLabels && <PaneTitleDetail {...titleB} />}
{sourceLabels && titleB.detail && <span className={styles.labelFile}>{titleB.detail}</span>}
{eolDiffers && eolB && <span className={styles.badge}>{badgeB}</span>}
</span>
</div>
+1 -20
View File
@@ -405,12 +405,9 @@
.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;
@@ -440,22 +437,6 @@
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;
}
@@ -0,0 +1,70 @@
.chooser > [data-dialog-body] {
display: flex;
overflow: hidden;
}
.content {
display: flex;
flex: 1;
flex-direction: column;
min-width: 0;
min-height: 0;
gap: var(--space-2);
padding: var(--space-2) var(--space-4) 0;
font-size: var(--fs-ui);
}
.tree {
flex: 1;
min-height: 0;
border: 1px solid var(--border);
border-radius: var(--radius-small);
background: var(--bg-input);
overflow: hidden;
}
.choice {
flex: 1;
min-width: 0;
}
.entry {
display: flex;
align-items: center;
gap: var(--space-1);
min-width: 0;
}
.entry svg {
flex: none;
}
.path {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.selected {
display: flex;
flex-direction: column;
flex: 0 1 auto;
min-height: 0;
max-height: min(96px, 33%);
padding-inline: var(--space-2);
overflow: auto;
}
.selected .choice {
flex: none;
min-height: var(--h-list-row);
}
.error {
max-height: 25%;
overflow: auto;
overflow-wrap: anywhere;
color: var(--danger);
}
+49 -14
View File
@@ -1,5 +1,5 @@
import { useState } from "react";
import { Checkbox, Dialog, SearchField, Tree } from "@/ui";
import { Checkbox, Dialog, Icon, SearchField, Tree, fileIconName } from "@/ui";
import { projectFs } from "@/features/project-tree/fs";
import { openDialog } from "./dialogs";
import { dirName, relTo, stripSlash } from "./model";
@@ -7,6 +7,7 @@ import { repoName, repoOf } from "./store";
import { call, commands } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { ipcPath, isSameOrInside } from "@/platform/paths";
import styles from "./PathFilterDialog.module.css";
interface PathNode {
path: string;
@@ -167,15 +168,21 @@ function PathFilterDialog({
<Dialog
open
title="Filter by Paths"
width={560}
className={styles.chooser}
width={432}
initialSize={{ w: 432, h: 392 }}
resizable="both"
minWidth={300}
minHeight={220}
onClose={() => onDone(null)}
buttons={[
{ label: "OK", role: "default", onClick: () => onDone([...checked]) },
{ label: "Cancel", role: "cancel" },
]}
>
<div style={{ height: 320 }}>
<div className={styles.content}>
<Tree<PathNode>
className={styles.tree}
roots={nodes}
getKey={(n) => n.path}
getLabel={(n) => n.name}
@@ -183,21 +190,49 @@ function PathFilterDialog({
isExpandable={(n) => n.directory}
loadChildren={load}
renderNode={(n) => (
<Checkbox label={n.name} checked={checked.has(n.path)} onChange={(on) => toggle(n.path, on)} />
<Checkbox
className={styles.choice}
label={
<span className={styles.entry}>
<Icon name={n.directory ? "folder" : fileIconName(n.name, n.path)} size={16} />
<span className={styles.path} title={n.name}>
{n.name}
</span>
</span>
}
checked={checked.has(n.path)}
onChange={(on) => toggle(n.path, on)}
/>
)}
aria-label="Files and folders"
/>
{checked.size > 0 && (
<div className={styles.selected} role="group" aria-label={tx("Selected paths")}>
{[...checked].map((path) => {
const root = roots.includes(path) ? path : repoOf(path, roots);
const label = root ? (path === root ? repoName(root) : `${repoName(root)}/${relTo(root, path)}`) : path;
return (
<Checkbox
key={path}
className={styles.choice}
label={
<span className={styles.path} title={label}>
{label}
</span>
}
checked
onChange={(on) => toggle(path, on)}
/>
);
})}
</div>
)}
{error && (
<div className={styles.error} role="alert">
{error}
</div>
)}
</div>
{checked.size > 0 && (
<div style={{ maxHeight: 100, overflow: "auto" }} aria-label="Selected paths">
{[...checked].map((path) => {
const root = roots.includes(path) ? path : repoOf(path, roots);
const label = root ? (path === root ? repoName(root) : `${repoName(root)}/${relTo(root, path)}`) : path;
return <Checkbox key={path} label={label} checked onChange={(on) => toggle(path, on)} />;
})}
</div>
)}
{error && <div role="alert">{error}</div>}
</Dialog>
);
}
+6 -2
View File
@@ -10,7 +10,6 @@ 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";
@@ -152,9 +151,14 @@ 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")}>
<CommitMessageContent commit={commit} message={commit.message.trimEnd() || commit.summary} />
<div className={styles.pushCommitMessage}>{commit.message.trimEnd() || commit.summary}</div>
<div className={styles.fileDir}>
{commit.shortId} {commit.author} &lt;{commit.email}&gt;
{date ? " " + tx`on ${date}` : ""}
</div>
</section>
);
}
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { fireEvent, render, screen, within } from "@testing-library/react";
import { fireEvent, render, screen } from "@testing-library/react";
import type { Commit } from "@/bindings";
const { files, combined, executeAction } = vi.hoisted(() => ({
@@ -69,10 +69,8 @@ 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" });
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(details.textContent).toContain("Add order service\n\nIntroduces the service.");
expect(details.textContent).toContain("aaaaaaa me <[email protected]> on ");
expect(await screen.findByText("src/orders")).toBeTruthy();
expect(screen.getAllByRole("treeitem")).toHaveLength(2);
const grouping = screen.getByRole("button", { name: "Group by Directory" });
+8
View File
@@ -363,6 +363,9 @@
.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;
@@ -371,6 +374,11 @@
-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;
+34 -18
View File
@@ -1,8 +1,10 @@
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";
@@ -35,7 +37,7 @@ export function RefLabels({
}) {
const labels = refLabels(refs, { compact, tagNames }, remoteNames);
return (
<span className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}>
<span className={clsx(styles.refs, 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>}
@@ -48,25 +50,39 @@ 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)}>
<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>
}
/>
<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} &lt;{commit.email}&gt;
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
</div>
{!compact &&
commit.committer &&
(commit.committer !== commit.author ||
+1 -3
View File
@@ -134,9 +134,7 @@ function CommitRowView({
setTooltip(false);
}}
>
<span className={styles.subjectText}>
<IssueText text={c.summary} />
</span>
<IssueText text={c.summary} />
</span>
{!opts.refsOnLeft && refs}
</span>