Compare commits

...
Author SHA1 Message Date
l0ng-ai 98856fd5a1 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	e2e/debugVariablesLayout.spec.ts
2026-11-22 20:34:54 +08:00
l0ng-ai d3be99543d fix(run): anchor console fold controls in the gutter (#5198)
Expanded output has a collapse control beside its row in the Run console gutter. It stays at the left edge while long output scrolls horizontally. A fold at the start of the buffer keeps its control after expansion, and activating a focused fold control leaves process input alone.
2026-11-22 20:34:31 +08:00
l0ng-ai f0cc99a4c7 fix(vcs): give commit subjects room beside compact refs (#5191)
Give Git Log commit subjects room beside long reference labels. Compact References View keeps labels within about a third of the available text column, with the full reference on hover. References in the log use the small UI font and the layout works on either side of the subject.
2026-11-22 20:34:26 +08:00
l0ng-ai 8db16dea32 fix(editor): keep same-name tabs distinguishable (#5187)
Same-name editor tabs show the distinguishing directory before the filename. In a narrow split, the directory gives up space first and the filename stays intact when it fits. The Hidden Tabs picker uses the same path label.
2026-11-22 20:34:21 +08:00
l0ng-ai 6a7297519c fix(settings): keep the current page visible in breadcrumbs (#5196)
Keep the current page name visible as the Settings pane narrows. Parent labels shorten first, and the breadcrumb tooltip shows the full path.
2026-11-22 20:33:01 +08:00
l0ng-ai 08362db3ca fix(run): keep the test summary together and clarify its status (#5186)
Keep elapsed time beside the test counts in the Run window at the same text size. The summary keeps its Running label when the first test has started and no results have arrived yet. A thin line below the summary shows the current state alongside the icon and counts.
2026-11-22 20:32:57 +08:00
l0ng-ai b7f3df0472 fix(debugger): keep values readable beside long type labels (#5185)
Keep debugger values readable beside long runtime types. The row reserves space for a value preview based on its length, so short values leave more room for names. A truncated type can still be read on hover, and the full type appears when the pane has room.
2026-11-22 20:32:52 +08:00
l0ng-ai c5824771c1 fix(editor): make workspace refactoring previews easier to scan (#5183)
Separate the filename from its directory in workspace refactoring previews. This gives same-named files distinct locations and frees space for rename targets and occurrence counts. Hovering a file or a rename target shows its full path.
2026-11-22 20:32:47 +08:00
l0ng-ai 40e5f9b7b3 fix(usages): distinguish files with the same name in the popup (#5181)
Add a muted directory caption beside each filename that appears in more than one file in Show Usages. Identical filenames, line numbers and snippets can otherwise make two results indistinguishable until selected. The popup uses the same directory labels as editor tabs, including a longer suffix when directory names repeat at different depths.
2026-11-22 20:32:41 +08:00
l0ng-ai 8bc82d08c6 fix(vcs): give outgoing commit messages a clear subject (#5180)
Give the selected commit's subject a stronger weight and separate it from the body in the Push dialog. The preview uses the editor's font settings for the message and compact text for the revision, author and date, matching the message hierarchy in Git Log.
2026-11-22 20:32:23 +08:00
l0ng-ai b0473f17b5 fix(run): keep the configuration header visible while scrolling (#5175)
Keep the configuration name and project-file checkbox visible above the scrolling options in Run/Debug Configurations. Long forms previously scrolled these controls out of view, so editing the name or changing where a configuration is saved meant returning to the top.
2026-11-22 20:31:59 +08:00
l0ng-ai 21264641ba fix(search): clarify Recent Locations file captions (#5170)
Recent Locations now shows the filename once, with a symbol breadcrumb or its parent directory beside it. Directory captions distinguish entries with the same filename, and hovering over a caption reveals the full project-relative path.
2026-11-22 20:31:00 +08:00
l0ng-ai 3ce4578600 fix(editor): separate quick fixes in the intentions popup (#5167)
Separate quick fixes from other actions in the Intentions popup with a divider. The divider is skipped during keyboard navigation and disappears when filtering leaves a single group. The popup keeps the chosen action selected when more results arrive from the language server.
2026-11-22 20:30:36 +08:00
l0ng-ai ca05825d7c fix(debugger): stabilize the inline variable editor 2026-11-22 17:50:58 +08:00
40 changed files with 1126 additions and 311 deletions

No files matched your search

+52
View File
@@ -715,6 +715,58 @@ test("rename keeps the typed name, uses the editor font and shows long preview n
await expect.poll(() => ipcCalls(page, "apply_workspace_edit")).toHaveLength(1);
});
test("intentions separate quick fixes from other actions and navigate across the divider", async ({
workbench: page,
}) => {
const editor = await openSample(page);
const fix = "Correct the Order type";
const refactor = "Extract the order value";
await page.evaluate(
({ file, edit, fix, refactor }) => {
const action = (title: string, kind: string, newText: string) => ({
title,
kind,
isPreferred: false,
disabledReason: null,
edit: { files: [{ kind: "edit", path: file, edits: [{ range: edit, new_text: newText }] }] },
command: null,
data: null,
server: 1,
});
window.__ipc.handlers.lsp_code_actions = () => [
action(refactor, "refactor.extract", "ExtractedOrder"),
action(fix, "quickfix", "CorrectOrder"),
];
window.__ipc.handlers.lsp_execute_code_action = () => [];
},
{ file: FILE, edit: range(20, 19, 24), fix, refactor },
);
await caretAt(editor, page, "val order: Order", "Order ");
await page.keyboard.press("Alt+Enter");
const popup = page.getByRole("dialog", { name: "Intentions", exact: true });
const list = popup.getByRole("listbox", { name: "Intentions" });
const divider = list.locator("[class*=listDivider]");
const preview = popup.locator('[aria-label="Preview"] pre');
await expect(list.getByRole("option", { name: fix })).toBeVisible();
await page.keyboard.type("order");
await expect(list.getByRole("option")).toHaveText([fix, refactor]);
await expect(divider).toHaveCount(1);
await expect(list.getByRole("option", { name: fix })).toHaveAttribute("aria-selected", "true");
await expect(preview).toContainText("CorrectOrder");
await list.press("ArrowDown");
await expect(list.getByRole("option", { name: refactor })).toHaveAttribute("aria-selected", "true");
await expect(preview).toContainText("ExtractedOrder");
for (const _character of "order") await list.press("Backspace");
await page.keyboard.type("extract");
await expect(list.getByRole("option")).toHaveText([refactor]);
await expect(divider).toHaveCount(0);
await list.press("Enter");
await expect(popup).toBeHidden();
await expect.poll(() => ipcCalls(page, "lsp_execute_code_action")).toHaveLength(1);
});
test("intention previews fit narrow windows and wrap long code lines", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1600, height: 900 });
const editor = await openSample(page);
+151 -34
View File
@@ -4,61 +4,178 @@ const amountName = "regionalSettlementAmountFromExternalProcessorBeforeRounding"
const routingName = "settlementRoutingReferenceForCrossBorderReconciliation";
const routingText = "APR-2026 / eu-west / batch-701 / settlement complete";
const routingValue = "'" + routingText + "'";
const invalidValueMessage = "The settlement amount must be a valid decimal expression.";
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1220, height: 760 });
test.describe("a paused session with editable values", () => {
test.beforeEach(async ({ workbench: page }) => {
await page.setViewportSize({ width: 1220, height: 760 });
await stubDesktop(page);
await page.evaluate(
async ({ amountName, routingName, routingValue, invalidValueMessage }) => {
const debugModule = "/src/features/debugger/state.ts";
const layoutModule = "/src/workbench/toolwindows/store.ts";
const servicesModule = "/src/workbench/contributions.ts";
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
const h = window.__ipc.handlers;
let amountValue = "47.74";
const amount = () => ({
name: amountName,
value: amountValue,
typeName: "float",
variablesReference: 0,
evaluateName: amountName,
});
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
h.debug_variables = () => [
amount(),
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
];
h.debug_set_variable = ({ value }) => {
if (value === "invalid") throw { kind: "invalid", message: invalidValueMessage, detail: null };
amountValue = String(value);
return amount();
};
adoptSession(91, {
name: "Checkout",
adapter: "debugpy",
status: "paused",
selectedFrame: 11,
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
});
moveToolWindow("debug", "right");
setToolWindowSize("right", 390);
toolWindowService().show("debug", true);
},
{ amountName, routingName, routingValue, invalidValueMessage },
);
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
});
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
const debug = page.getByRole("region", { name: "Debug", exact: true });
const amount = debug.getByText("47.74", { exact: true });
await expect
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
.toBe(true);
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
const show = routing.getByTitle("Show", { exact: true });
await expect(show).toBeInViewport({ ratio: 1 });
await show.click();
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
await page.setViewportSize({ width: 1640, height: 760 });
await page.evaluate(async () => {
const layoutModule = "/src/workbench/toolwindows/store.ts";
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
moveToolWindow("debug", "bottom");
});
await expect(show).toBeHidden();
await expect
.poll(() =>
routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1),
)
.toBe(true);
});
test("keeps the variable label and input in place when editing a value", async ({ workbench: page }) => {
const debug = page.getByRole("region", { name: "Debug", exact: true });
const row = debug.getByRole("treeitem").filter({ hasText: amountName });
const name = row.getByText(amountName, { exact: true });
await row.click();
const nameBefore = (await name.boundingBox())!;
const equal = row.getByText("=", { exact: true });
const equalBefore = (await equal.boundingBox())!;
const color = await name.evaluate((el) => getComputedStyle(el).color);
await page.keyboard.press("F2");
const input = row.getByRole("textbox", { name: `New value of ${amountName}` });
await expect(input).toBeFocused();
await expect(input).toHaveValue("47.74");
await expect(name).toHaveCSS("color", color);
expect((await name.boundingBox())!.x).toBeCloseTo(nameBefore.x, 0);
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
await expect(row.locator("svg")).toHaveCount(1);
await input.fill("invalid");
await input.press("Enter");
await expect(input).toHaveAttribute("aria-invalid", "true");
await expect(input).toHaveAttribute("title", invalidValueMessage);
await expect(input).toBeInViewport({ ratio: 1 });
expect((await input.boundingBox())!.width).toBeGreaterThan(60);
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
await input.press("Escape");
await expect(input).toBeHidden();
await expect(row).toContainText("47.74");
await page.keyboard.press("F2");
await expect(input).toHaveValue("47.74");
await input.fill("48.25");
await input.press("Enter");
await expect(input).toBeHidden();
await expect(row).toContainText("48.25");
});
});
test("keeps a decimal value legible beside a long runtime type", async ({ workbench: page }) => {
const name = "dailySettlementTotal";
const type = "ExactSettlementAmountForCrossBorderReconciliation";
const value = "12486245.8067";
const countName = "pendingInvoices";
await page.setViewportSize({ width: 1100, height: 720 });
await stubDesktop(page);
await page.evaluate(
async ({ amountName, routingName, routingValue }) => {
async ({ name, type, value, countName }) => {
const debugModule = "/src/features/debugger/state.ts";
const layoutModule = "/src/workbench/toolwindows/store.ts";
const servicesModule = "/src/workbench/contributions.ts";
const serviceModule = "/src/workbench/contributions.ts";
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
const h = window.__ipc.handlers;
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
h.debug_variables = () => [
{ name: amountName, value: "47.74", typeName: "float", variablesReference: 0, evaluateName: amountName },
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
const { toolWindowService } = await import(/* @vite-ignore */ serviceModule);
window.__ipc.handlers.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
window.__ipc.handlers.debug_variables = () => [
{ name, value, typeName: type, variablesReference: 0, evaluateName: name },
{ name: countName, value: "327", typeName: "int", variablesReference: 0, evaluateName: countName },
];
adoptSession(91, {
name: "Checkout",
adoptSession(92, {
name: "Settlement",
adapter: "debugpy",
status: "paused",
selectedFrame: 11,
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
frames: [{ id: 11, name: "settle", path: null, line: 0, column: 0, presentationHint: null }],
});
moveToolWindow("debug", "right");
setToolWindowSize("right", 390);
setToolWindowSize("right", 280);
toolWindowService().show("debug", true);
},
{ amountName, routingName, routingValue },
{ name, type, value, countName },
);
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
const amount = debug.getByText("47.74", { exact: true });
await expect
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
.toBe(true);
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
const show = routing.getByTitle("Show", { exact: true });
await expect(show).toBeInViewport({ ratio: 1 });
await show.click();
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
const variable = debug.getByRole("treeitem").filter({ hasText: name });
const amount = variable.getByText(value, { exact: true });
const annotation = variable.getByTitle(`{${type}}`, { exact: true });
await expect(amount).toBeVisible();
await expect.poll(() => amount.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect(variable.getByTitle("Show", { exact: true })).toBeHidden();
await expect(annotation).toBeVisible();
await page.setViewportSize({ width: 1640, height: 760 });
const shortValueName = debug.getByText(countName, { exact: true });
await expect.poll(() => shortValueName.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await page.setViewportSize({ width: 1440, height: 760 });
await page.evaluate(async () => {
const layoutModule = "/src/workbench/toolwindows/store.ts";
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
moveToolWindow("debug", "bottom");
setToolWindowSize("bottom", 310);
});
await expect(show).toBeHidden();
await expect
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
.toBe(true);
await expect.poll(() => annotation.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
});
+46
View File
@@ -69,3 +69,49 @@ test("the bottom single row keeps a long selected tab visible alongside the hidd
await pane.getByRole("tab", { name: shortFile, exact: true }).press("End");
await expectCloseToFit(tab);
});
test("same-name tabs keep the filename beside a shortened directory", async ({ workbench: page }) => {
const filename = "AllocationRule.ts";
const first = "qa";
const second = "backoffice-reconciliation";
await openSplit(page, [`${first}/${filename}`, `${second}/${filename}`], "top");
await page.setViewportSize({ width: 900, height: 760 });
const pane = page.locator("section[data-pane-id]").filter({
has: page.getByRole("tab").filter({ hasText: second }),
});
const selected = pane.getByRole("tab").filter({ hasText: second });
await expect(selected).toHaveText(`${second}/${filename}`);
await expectCloseToFit(selected);
const directory = selected.getByText(`${second}/`, { exact: true });
const name = selected.getByText(filename, { exact: true });
await expect.poll(() => directory.evaluate((el) => el.clientWidth > 0 && el.scrollWidth > el.clientWidth)).toBe(true);
await expect
.poll(() =>
name.evaluate((el) => {
const text = document.createRange();
text.selectNodeContents(el);
return el.getBoundingClientRect().width >= text.getBoundingClientRect().width;
}),
)
.toBe(true);
await pane.getByRole("button", { name: "Show Hidden Tabs" }).click();
const picker = page.getByRole("grid", { name: "Hidden Editor Tabs" });
await expect(picker.getByRole("gridcell").filter({ hasText: `${first}/${filename}` })).toBeVisible();
await page.keyboard.press("Enter");
const firstTab = pane.getByRole("tab").filter({ hasText: first });
await expectCloseToFit(firstTab);
await expect
.poll(() =>
firstTab.getByText(`${first}/`, { exact: true }).evaluate((el) => {
const text = document.createRange();
text.selectNodeContents(el);
return Math.abs(el.clientWidth - text.getBoundingClientRect().width);
}),
)
.toBeLessThanOrEqual(1);
await firstTab.locator("..").getByRole("button", { name: "Close Tab", exact: true }).click();
await expect(page.getByRole("tab", { name: filename, exact: true })).toHaveAttribute("aria-selected", "true");
});
+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 ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
test("keeps expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
const branch = "origin/feature/workspace-settings";
const tag = "v2.1";
const summary = "Keep workspace settings and commit references visible ".repeat(4).trim();
@@ -127,7 +127,7 @@ test("keeps ref names visible when a long commit subject competes for space", as
const options = "/src/features/vcs/logOptions.ts";
const { useGitLog } = await import(/* @vite-ignore */ log);
const { useLogOptions } = await import(/* @vite-ignore */ options);
useLogOptions.setState({ tagNames: true });
useLogOptions.setState({ tagNames: true, compactRefs: false });
const [first, ...rest] = useGitLog.getState().commits;
useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] });
},
+51
View File
@@ -112,6 +112,57 @@ test("Git Log separates commit message typography from compact metadata", async
await expect(author).toHaveCSS("font-size", "12px");
});
test("compact Git Log refs give the subject room on either side", async ({ workbench: page }) => {
await page.setViewportSize({ width: 630, height: 720 });
const refSubject = "Reconcile shipping credits";
const longReference = "release-quarterly-settlement-and-backoffice-invoice-reconciliation";
await page.evaluate(
async ({ refSubject, longReference }) => {
const optionsModule = "/src/features/vcs/logOptions.ts";
const logModule = "/src/features/vcs/logStore.ts";
const { setLogOptions } = await import(/* @vite-ignore */ optionsModule);
const { useGitLog } = await import(/* @vite-ignore */ logModule);
setLogOptions({ showBranches: false, showDetails: false });
const [first, ...rest] = useGitLog.getState().commits;
useGitLog.setState({
commits: [{ ...first, summary: refSubject, message: refSubject, refs: [longReference] }, ...rest],
});
},
{ refSubject, longReference },
);
const row = page.getByRole("listbox", { name: "Commits" }).getByRole("option").filter({ hasText: refSubject });
const subject = row.getByText(refSubject, { exact: true });
const ref = row.getByTitle(longReference, { exact: true });
const expectLayout = async () => {
await expect
.poll(() =>
subject.evaluate((el) => {
const text = document.createRange();
text.selectNodeContents(el);
return el.getBoundingClientRect().width + 0.02 >= text.getBoundingClientRect().width;
}),
)
.toBe(true);
await expect
.poll(() =>
ref.evaluate((el) => {
const refs = el.parentElement!;
return refs.clientWidth / refs.parentElement!.clientWidth;
}),
)
.toBeLessThanOrEqual(0.34);
await expect(ref).toHaveCSS("font-size", "12px");
await expect(subject).toHaveCSS("font-size", "13px");
};
await expectLayout();
await expect.poll(async () => (await subject.boundingBox())!.x < (await ref.boundingBox())!.x).toBe(true);
await page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "View Options" }).click();
await page.getByRole("menuitemcheckbox", { name: "References on the Left" }).click();
await expectLayout();
await expect.poll(async () => (await subject.boundingBox())!.x > (await ref.boundingBox())!.x).toBe(true);
});
test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => {
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" });
+23 -1
View File
@@ -176,7 +176,29 @@ test("Push keeps commit subjects and changed files readable in a narrow window",
await expect(input).toHaveValue("main");
await expect(dialog.getByRole("button", { name: "Push", exact: true })).toBeInViewport();
const details = dialog.getByRole("region", { name: "Commit details" });
await expect(details).toContainText("Keep the new totals consistent with receipts.");
await page.evaluate(async () => {
const project = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ project);
const { settings } = useProject.getState();
useProject.setState({
settings: {
...settings,
editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18, fontWeight: 400, boldFontWeight: 700 },
},
});
});
const messageSubject = details.getByText(OUTGOING, { exact: true });
const messageBody = details.getByText("Keep the new totals consistent with receipts.", { exact: true });
await expect(messageSubject).toHaveCSS("font-weight", "700");
await expect(messageBody).toHaveCSS("font-weight", "400");
await expect(messageSubject).toHaveCSS("font-size", "18px");
await expect(messageBody).toHaveCSS("font-size", "18px");
await expect(messageBody).toHaveCSS("font-family", /Consolas/);
const metadata = details.getByText(/Sam Rivera <sam@example\.com>/);
await expect(metadata).toHaveCSS("font-size", "12px");
await metadata.scrollIntoViewIfNeeded();
await expect(metadata).toBeInViewport();
expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect
.poll(async () => {
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
+39
View File
@@ -93,3 +93,42 @@ test("Recent Locations keeps all snippet lines visible when the editor font grow
await expect(row.getByText("changed", { exact: true })).toBeInViewport({ ratio: 1 });
await expect(filter).toBeFocused();
});
test("Recent Locations shows each file name once with its parent directory", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async () => {
const tracking = "/src/features/search/common/tracking.ts";
const { useTracking } = await import(/* @vite-ignore */ tracking);
const now = Date.now();
useTracking.setState({
locations: [
["README.md", "# Shop API"],
["packages/billing/Routes.ts", "registerBillingRoutes();"],
["packages/checkout/Routes.ts", "registerCheckoutRoutes();"],
].map(([path, snippet], index) => ({
path: `/dev/acme-api/${path}`,
line: 0,
col: 0,
changed: false,
time: now - index * 60000,
snippet: [snippet],
snippetStart: 0,
})),
});
});
await openRecent(page, "recentLocations");
const dialog = page.getByRole("dialog", { name: "Recent Locations", exact: true });
const rows = dialog.getByRole("option");
await expect(rows).toHaveCount(3);
await expect(rows.filter({ hasText: "# Shop API" }).getByText("README.md", { exact: true })).toHaveCount(1);
const billing = rows.filter({ hasText: "registerBillingRoutes();" });
const checkout = rows.filter({ hasText: "registerCheckoutRoutes();" });
await expect(billing.getByText("packages/billing", { exact: true })).toBeVisible();
await expect(checkout.getByText("packages/checkout", { exact: true })).toBeVisible();
await expect(checkout.getByTitle("packages/checkout/Routes.ts", { exact: true })).toBeVisible();
await dialog.getByRole("textbox", { name: "Filter recent locations" }).fill("packages/checkout");
await expect(rows).toHaveCount(1);
await expect(rows.first()).toContainText("registerCheckoutRoutes();");
});
+63
View File
@@ -0,0 +1,63 @@
import { expect, test } from "./fixtures";
test("the workspace refactoring preview separates filenames from directories and keeps outcomes readable", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 420, height: 620 });
await page.evaluate(async () => {
const popupPath = "/src/editor/lsp/popupStore.ts";
const editPath = "/src/editor/lsp/workspaceEdit.ts";
const { openPopup } = await import(/* @vite-ignore */ popupPath);
const { summarizeWorkspaceEdit } = await import(/* @vite-ignore */ editPath);
const root = "/dev/acme-api";
const edit = {
range: { start: { line: 0, col: 0 }, end: { line: 0, col: 9 } },
new_text: "postInvoice",
};
openPopup({
kind: "preview",
title: "Rename 'saveOrder' to 'postInvoice'",
summary: summarizeWorkspaceEdit({
files: [
{ kind: "edit", path: `${root}/README.md`, edits: [edit] },
{ kind: "edit", path: `${root}/packages/billing/src/Routes.ts`, edits: [edit, edit] },
{ kind: "edit", path: `${root}/packages/checkout/src/Routes.ts`, edits: [edit] },
{
kind: "rename",
from: `${root}/packages/checkout/src/Invoice.ts`,
to: `${root}/packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts`,
},
],
}),
renameThemeClasses: "",
confirmLabel: "Do Refactor",
onConfirm: () => {
document.body.dataset.refactorConfirmed = "true";
},
});
});
const dialog = page.getByRole("dialog", { name: "Rename 'saveOrder' to 'postInvoice'" });
const rows = dialog.getByRole("list", { name: "Changes" }).getByRole("listitem");
await expect(rows).toHaveCount(4);
await expect(dialog.getByText("4 occurrences in 4 files")).toBeVisible();
const root = rows.filter({ hasText: "README.md" });
await expect(root.getByText("README.md", { exact: true })).toHaveCount(1);
const billing = rows.filter({ hasText: "2 occurrences" });
await expect(billing.getByText("Routes.ts", { exact: true })).toBeVisible();
await expect(billing.getByText("packages/billing/src", { exact: true })).toBeVisible();
await expect(billing.getByTitle("packages/billing/src/Routes.ts", { exact: true })).toBeVisible();
const checkout = rows.filter({ hasText: "packages/checkout/src" }).filter({ hasText: "Routes.ts" });
await expect(checkout.getByText("packages/checkout/src", { exact: true })).toBeVisible();
const rename = rows.filter({ hasText: "Invoice.ts" });
const target = rename.getByText("→ InvoiceReconciliationForInternationalOrders.ts", { exact: true });
await expect(target).toBeVisible();
await expect(target).toHaveAttribute("title", "packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts");
expect((await target.boundingBox())!.width).toBeGreaterThan(35);
await expect(dialog.getByRole("button", { name: "Do Refactor", exact: true })).toBeInViewport();
await dialog.getByRole("button", { name: "Do Refactor", exact: true }).click();
await expect(dialog).toBeHidden();
await expect(page.locator("body")).toHaveAttribute("data-refactor-confirmed", "true");
});
+125
View File
@@ -76,6 +76,73 @@ test("⌃R runs the selected configuration and shows its output and exit", async
expect(started).toMatchObject({ config: { id: "npm:dev", command: "npm", args: ["run", "dev"] } });
});
test("expanded console folds stay reachable at the start of their rows", async ({ workbench: page }) => {
const heading = "Reconciling orders for the overnight settlement and inventory reporting pipeline";
await stubRun(
page,
[
{
kind: "stdout",
text: [
"TRACE Reused inventory connection",
"TRACE Loaded warehouse configuration",
heading,
"TRACE Checked warehouse audit result",
"TRACE Updated inventory snapshot",
"Processed 24 orders",
"",
].join("\n"),
},
],
null,
);
await page.evaluate(async () => {
const projectModule = "/src/platform/project.ts";
const layoutModule = "/src/workbench/toolwindows/store.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
const { settings } = useProject.getState();
useProject.setState({
settings: { ...settings, console: { ...settings?.console, foldPatterns: ["TRACE "] } },
});
moveToolWindow("run", "right");
setToolWindowSize("right", 320);
});
await page.keyboard.press("Control+r");
const log = page.getByRole("region", { name: "Run", exact: true }).getByRole("log");
const expand = log.getByTitle("Expand folded lines", { exact: true });
const collapse = log.getByRole("button", { name: "Collapse folded lines", exact: true });
await expect(expand).toHaveCount(2);
await expand.first().click();
await expect(log.getByText("TRACE Reused inventory connection", { exact: true })).toBeVisible();
await expect(collapse).toHaveCount(1);
await collapse.press("Space");
await expect(expand).toHaveCount(2);
await expand.first().press("Enter");
await expect(collapse).toBeFocused();
await expand.last().click();
await expect(collapse).toHaveCount(2);
for (const scrollLeft of [0, 120]) {
await log.evaluate((element, x) => (element.scrollLeft = x), scrollLeft);
expect(await log.evaluate((element) => element.scrollLeft)).toBe(scrollLeft);
for (const control of await collapse.all()) {
const aligned = await control.evaluate((button) => {
const log = button.closest('[role="log"]')!.getBoundingClientRect();
const row = button.closest("[data-index]")!.getBoundingClientRect();
const box = button.getBoundingClientRect();
return Math.abs(box.left - log.left) <= 1 && box.top >= row.top && box.bottom <= row.bottom + 1;
});
expect(aligned).toBe(true);
}
}
await collapse.first().click();
await collapse.first().click();
await expect(expand).toHaveCount(2);
expect(await ipcCalls(page, "run_stdin")).toEqual([]);
});
test("⌘F2 stops a running process", async ({ workbench: page }) => {
await stubRun(page, [{ kind: "stdout", text: "Watching for changes…\n" }], null);
await page.keyboard.press("Control+r");
@@ -323,6 +390,64 @@ test("test results keep counts, actions and selected output visible as the pane
await expect(output).toContainText(message);
});
test("test results keep elapsed time beside the counts", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1060, height: 740 });
const lines = [
"test_tax (test_ledger.CheckoutTests.test_tax) ... ok",
"test_refund (test_ledger.CheckoutTests.test_refund) ... FAIL",
"test_callback (test_ledger.CheckoutTests.test_callback) ... skipped 'Requires a callback'",
"Ran 3 tests in 0.170s",
"FAILED (failures=1, skipped=1)",
];
await stubRun(page, [{ kind: "stderr", text: lines.join("\n") + "\n" }], 1, {
id: "django:checkout-tests",
name: "Checkout tests",
kind: "django-test",
command: "python",
args: ["manage.py", "test", "-v", "2"],
isTest: true,
});
await page.keyboard.press("Control+r");
const run = page.getByRole("region", { name: "Run", exact: true });
const summary = run.getByRole("status").filter({ hasText: "1 failing" });
const ignored = summary.getByText("1 ignored", { exact: true });
const elapsed = summary.getByText("170 ms", { exact: true });
await expect(elapsed).toBeVisible();
for (const width of [1060, 540]) {
await page.setViewportSize({ width, height: 740 });
await expect
.poll(async () => {
const [count, duration] = await Promise.all([ignored.boundingBox(), elapsed.boundingBox()]);
return count && duration && Math.abs(count.y - duration.y) <= 1 ? duration.x - count.x - count.width : Infinity;
})
.toBeLessThanOrEqual(12);
}
await expect(summary).toHaveCSS("border-bottom-width", "2px");
});
test("test results retain a running label after the first test starts", async ({ workbench: page }) => {
const name = "TestCheckoutTotals";
await stubRun(
page,
[{ kind: "stdout", text: JSON.stringify({ Package: "example.com/checkout", Action: "run", Test: name }) + "\n" }],
null,
{
id: "go:checkout-tests",
name: "Checkout tests",
kind: "go",
command: "go",
args: ["test", "-json"],
isTest: true,
},
);
await page.keyboard.press("Control+r");
const run = page.getByRole("region", { name: "Run", exact: true });
await expect(run.getByRole("treeitem", { name: new RegExp(name) })).toBeVisible();
const summary = run.getByRole("status").filter({ hasText: "Running…" });
await expect(summary).toBeVisible();
await expect(summary).toHaveCSS("border-bottom-width", "2px");
});
test("test results group failure navigation and let users hide row durations", async ({ workbench: page }) => {
await page.setViewportSize({ width: 540, height: 740 });
const first = "TestCheckoutTotalsWithTaxRoundingAndPendingRefunds";
+8 -2
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 scrolls only inside the panes at ${height}px`, async ({
test(`run configurations dialog keeps its toolbar and name visible while scrolling at ${height}px`, async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 900, height });
@@ -62,9 +62,13 @@ async function resize(page: Page, dialog: Locator, dy: number) {
async function checkScrolling(page: Page, dialog: Locator) {
const body = dialog.locator("[data-dialog-body]");
const list = dialog.getByRole("tree", { name: "Run configurations", exact: true });
const form = dialog.locator('[class*="_editForm_"]');
const form = dialog.locator('[class*="_formSettings_"]');
const nameField = dialog.getByRole("textbox", { name: "Name", exact: true });
await list.evaluate((el) => (el.scrollTop = 0));
await form.evaluate((el) => (el.scrollTop = 0));
// Measure once the dialog's opening animation has settled.
await dialog.evaluate((el) => Promise.all(el.getAnimations().map((animation) => animation.finished)));
const nameTop = (await nameField.boundingBox())!.y;
await list.hover();
await page.mouse.wheel(0, 200);
await expect.poll(() => list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
@@ -74,6 +78,8 @@ async function checkScrolling(page: Page, dialog: Locator) {
await page.mouse.wheel(0, 200);
await expect.poll(() => form.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
expect(await list.evaluate((el) => el.scrollTop)).toBe(listTop);
expect((await nameField.boundingBox())!.y).toBeCloseTo(nameTop, 0);
await expect(dialog.getByRole("checkbox", { name: /Store as project file/ })).toBeInViewport({ ratio: 1 });
const overflow = await body.evaluate((el) => ({
scroll: el.scrollHeight,
client: el.clientHeight,
+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*='editForm_']").evaluate((el) => el.scrollHeight - el.clientHeight))
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollHeight - el.clientHeight))
.toBeGreaterThan(0);
});
@@ -144,7 +144,7 @@ test("Java, npm and Python forms fit narrow and zoomed content panes", async ({
for (const width of [1024, 640, 520]) {
await page.setViewportSize({ width, height: 820 });
await expect
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
message: `${kind}, ${width}px, ${zoom * 100}%`,
})
.toBeLessThanOrEqual(1);
@@ -204,7 +204,7 @@ for (const locale of ["en", "zh"]) {
)
.toMatchObject({ overflow: expect.any(Number), footerFits: true, footerVisible: true });
await expect
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth))
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth))
.toBeLessThanOrEqual(1);
const tasks = dialog.getByRole("list");
await tasks.scrollIntoViewIfNeeded();
+33
View File
@@ -1,5 +1,38 @@
import { expect, test } from "./fixtures";
test("keeps the current settings page name readable when the path is wider than the pane", async ({
workbench: page,
}) => {
await page.keyboard.press("Meta+,");
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
const search = settings.getByRole("textbox", { name: "Search settings" });
await search.fill("Maven");
const path = settings.getByLabel("Breadcrumb", { exact: true });
const parent = path.getByText("Build, Execution, Deployment", { exact: true });
const current = path.getByText("Maven", { exact: true });
await expect(current).toBeVisible();
await search.clear();
for (const width of [400, 560, 1120]) {
await page.setViewportSize({ width, height: 720 });
await expect
.poll(() =>
current.evaluate((label) => {
const box = label.getBoundingClientRect();
const trail = label.closest("[aria-label=Breadcrumb]")!.getBoundingClientRect();
return label.clientWidth >= label.scrollWidth && box.width > 0 && box.right <= trail.right + 1;
}),
)
.toBe(true);
}
await expect(parent).toBeInViewport({ ratio: 1 });
expect(await parent.evaluate((label) => label.scrollWidth <= label.clientWidth)).toBe(true);
await settings.getByRole("button", { name: "Back", exact: true }).click();
await expect(current).toBeHidden();
await settings.getByRole("button", { name: "Forward", exact: true }).click();
await expect(current).toBeVisible();
});
test("dirty settings keep scope labels and navigation inside the page header", async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
+45
View File
@@ -0,0 +1,45 @@
import { expect, test } from "./fixtures";
test("Show Usages distinguishes same-named files without losing the line or snippet", async ({ workbench: page }) => {
await page.setViewportSize({ width: 480, height: 620 });
await page.evaluate(async () => {
const usages = "/src/features/code-insight/usages.ts";
const { useUsagesPopup } = await import(/* @vite-ignore */ usages);
const symbol = "submitOrder";
useUsagesPopup.setState({
open: true,
anchor: { x: 30, y: 90 },
symbol,
groups: (
[
["/dev/acme-api/packages/billing/src/Routes.ts", "return submitOrder(invoice);"],
["/dev/acme-api/packages/checkout/src/Routes.ts", "return submitOrder(cart);"],
["/dev/acme-api/src/Worker.ts", "await submitOrder(job);"],
] as const
).map(([path, text]) => {
const col = text.indexOf(symbol);
return { path, usages: [{ path, line: 6, col, endCol: col + symbol.length, text }] };
}),
});
});
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
const rows = popup.getByRole("option");
const billing = rows.filter({ hasText: "invoice" });
const checkout = rows.filter({ hasText: "cart" });
await expect(rows).toHaveCount(3);
for (const [row, directory] of [
[billing, "billing"],
[checkout, "checkout"],
] as const) {
await expect(row.getByText("Routes.ts", { exact: true })).toBeVisible();
const caption = row.getByText(directory, { exact: true });
await expect(caption).toBeVisible();
expect(await caption.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect(row.getByText("7", { exact: true })).toBeVisible();
await expect(row.locator("mark")).toHaveText("submitOrder");
}
await expect(checkout.getByTitle("/dev/acme-api/packages/checkout/src/Routes.ts", { exact: true })).toBeVisible();
await expect(rows.filter({ hasText: "Worker.ts" }).getByText("src", { exact: true })).toHaveCount(0);
});
+1
View File
@@ -40,6 +40,7 @@ import { rootOfPath } from "@/platform/projectRoots";
import { isVirtualUri } from "@/platform/virtualDocs";
import { cornerInset } from "@/editor/core/cm/cornerInset";
export { iconAreaSource, mapLineStart, type IconAreaSource } from "@/editor/core/cm/iconArea";
export { disambiguateTitles } from "@/editor/core/model/tabTitles";
export {
invalidateNavigationProviders,
navigationEpoch,
+6
View File
@@ -26,6 +26,12 @@ describe("disambiguateTitles", () => {
expect(m.get("/r/a/d/f.ts")).toBe("d");
});
it("distinguishes directory names that occur at different depths", () => {
const paths = ["/r/prod/shared/f.ts", "/r/shared/prod/f.ts", "/r/test/shared/f.ts"];
const labels = disambiguateTitles(paths);
expect(paths.map((path) => labels.get(path))).toEqual(["prod/shared", "shared/prod", "test"]);
});
it("ignores duplicates of the same path", () => {
expect(disambiguateTitles(["/p/a/x.ts", "/p/a/x.ts"]).size).toBe(0);
});
+19 -20
View File
@@ -1,6 +1,6 @@
/**
* IDEA-style editor tab titles for files that share a name: the nearest parent
* directory that tells them apart is shown after the name (`lib.rs — ide-lsp`
* Directory hints for files that share a name: a distinguishing parent
* directory is shown after the name (`lib.rs — ide-lsp`
* for `crates/ide-lsp/src/lib.rs` next to `crates/ide-vcs/src/lib.rs`).
*/
@@ -27,25 +27,24 @@ export function disambiguateTitles(paths: readonly string[], titleOf = baseName)
for (const group of groups.values()) {
if (group.length < 2) continue;
const dirs = group.map(parents);
const nameCounts = new Map<string, number>();
const suffixCounts = new Map<string, number>();
const suffixes = dirs.map((names) => {
for (const name of new Set(names)) {
nameCounts.set(name, (nameCounts.get(name) ?? 0) + 1);
}
let suffix = "";
return names.map((name) => {
suffix = suffix ? `${name}/${suffix}` : name;
suffixCounts.set(suffix, (suffixCounts.get(suffix) ?? 0) + 1);
return suffix;
});
});
group.forEach((path, i) => {
const own = dirs[i]!;
let hint: string | null = null;
for (let depth = 0; depth < own.length; depth++) {
const seg = own[depth]!;
if (dirs.every((other, j) => j === i || other[depth] !== seg)) {
hint = seg;
break;
}
}
if (hint === null) {
// No single directory is unique: the shortest distinguishing parent path.
const suffix = (d: string[], k: number) => d.slice(0, k).reverse().join("/");
for (let k = 2; k <= own.length && hint === null; k++) {
const mine = suffix(own, k);
if (dirs.every((other, j) => j === i || suffix(other, k) !== mine)) hint = mine;
}
}
out.set(path, hint ?? (own.length ? own.slice().reverse().join("/") : "/"));
const name = dirs[i]!.find((segment) => nameCounts.get(segment) === 1);
const paths = suffixes[i]!;
const hint = name ?? paths.find((suffix, depth) => depth > 0 && suffixCounts.get(suffix) === 1);
out.set(path, hint ?? paths.at(-1) ?? "/");
});
}
return out;
@@ -150,6 +150,28 @@
.deprecated {
text-decoration-line: line-through;
}
.tabPath {
--tab-directory-min: min(5ch, 25%);
display: flex;
}
.tabDirectory > span,
.tabFilename {
overflow: hidden;
text-overflow: ellipsis;
}
.tabDirectory {
flex: 0 1000 max-content;
/* Leave space for a short prefix without stretching one that already fits. */
width: var(--tab-directory-min);
color: var(--fg-subtle);
}
.tabDirectory > span {
display: block;
}
.tabFilename {
flex: none;
max-width: calc(100% - var(--tab-directory-min));
}
.dupe {
color: var(--fg-faint);
margin-left: 4px;
+10 -2
View File
@@ -219,15 +219,23 @@ function PaneView({ paneId }: { paneId: string }) {
const pin = t.pinned ? <Icon name="pin" size={11} className={styles.pin} label="Pinned" /> : null;
const file = t.input.kind === "file" && t.input.path ? files.get(t.input.path) : undefined;
const title = markModified && dirty[i] ? `*${name}` : name;
const prefix = t.input.kind === "file" && dupe ? (dupe.endsWith("/") ? dupe : `${dupe}/`) : null;
return {
id: t.id,
label: (
label: prefix ? (
<span className={styles.tabPath}>
<span className={styles.tabDirectory}>
<span>{prefix}</span>
</span>
<span className={clsx(styles.tabFilename, file?.deprecated && styles.deprecated)}>{title}</span>
</span>
) : (
<>
{file?.deprecated ? <span className={styles.deprecated}>{title}</span> : title}
{dupe && <span className={styles.dupe}>{dupe}</span>}
</>
),
text: dupe ? `${name} — ${dupe}` : name,
text: prefix ? `${prefix}${name}` : dupe ? `${name} — ${dupe}` : name,
icon: showFileIcon
? t.input.kind === "file" && t.input.path
? (tabIcons[i] ?? file?.icon)
+27 -18
View File
@@ -532,20 +532,6 @@
.renamePreview .previewList {
overflow: visible;
}
.renamePreview .previewName {
min-width: 0;
max-width: 55%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewOp {
flex: 0 1 auto;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.renamePreview .previewWarning {
overflow-wrap: anywhere;
}
@@ -571,23 +557,46 @@
padding: 0 14px;
font-size: var(--fs-ui);
}
.previewName {
color: var(--fg-emphasis);
.previewFile {
flex: 1 1 auto;
display: flex;
align-items: baseline;
gap: var(--space-2);
min-width: 0;
}
.previewPath {
.previewName,
.previewDirectory,
.previewOp {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.previewName {
flex: none;
max-inline-size: 100%;
color: var(--fg-emphasis);
}
.previewFile:has(.previewDirectory) .previewName {
max-inline-size: 70%;
}
.previewDirectory {
color: var(--fg-subtle);
font-size: var(--fs-small);
direction: rtl;
}
.previewOp,
.previewCount {
flex: none;
font-size: var(--fs-small);
color: var(--fg-muted);
}
.previewOp {
max-inline-size: 55%;
}
.previewCount {
flex: none;
font-variant-numeric: tabular-nums;
}
.previewWarning {
flex: none;
+26 -1
View File
@@ -15,7 +15,7 @@ vi.mock("@/workbench/contributions", async (orig) => {
});
const { LspPopups, DocumentationWindow } = await import("./Popups");
const { closePopup, openPopup, useLspPopup } = await import("./popupStore");
const { closePopup, openPopup, updatePopup, useLspPopup } = await import("./popupStore");
const { useDocWindow, hoverDoc, pushHistory, stepHistory, hoverCandidates } = await import("./docs");
const { mountHoverDoc } = await import("./DocView");
const { hoverSource } = await import("./hover");
@@ -139,6 +139,31 @@ describe("list popup", () => {
expect(onClose).toHaveBeenCalledOnce();
});
it("keeps the chosen intention when a quick-fix section arrives ahead of it", () => {
const local = ["Extract variable", "Inline value"].map((label) => ({
id: label,
label,
section: { id: "intentions" },
run: vi.fn(),
}));
openPopup({ kind: "list", title: "Intentions", anchor: { x: 0, y: 0 }, items: local, busy: true });
render(<LspPopups />);
fireEvent.keyDown(screen.getByRole("listbox"), { key: "ArrowDown" });
expect(screen.getByRole("option", { name: "Inline value", selected: true })).toBeVisible();
const runFix = vi.fn();
act(() =>
updatePopup("list", {
busy: false,
items: [{ id: "fix", label: "Correct type", section: { id: "quick-fixes" }, run: runFix }, ...local],
}),
);
expect(screen.getByRole("option", { name: "Inline value", selected: true })).toBeVisible();
fireEvent.keyDown(screen.getByRole("listbox"), { key: "Enter" });
expect(local[1]!.run).toHaveBeenCalledOnce();
expect(runFix).not.toHaveBeenCalled();
});
it("focuses the rows, not the header's pin button, when it opens", () => {
openPopup({
kind: "list",
+37 -29
View File
@@ -22,7 +22,7 @@ import {
selectableText,
T,
} from "@/ui";
import { basename, relativePath, useProject } from "@/platform/project";
import { basename, relativeDir, relativePath, useProject } from "@/platform/project";
import {
closePopup,
updatePopup,
@@ -112,14 +112,10 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
const [query, setQuery] = useState("");
const rows = useMemo(() => listPopupRows(popup.items, query), [popup.items, query]);
const firstEnabled = rows.findIndex((row) => row.kind === "action" && !row.item.disabled);
const [active, setActive] = useState(firstEnabled);
const clamped = Math.min(active, rows.length - 1);
const [activeId, setActiveId] = useState<string | null>(null);
const selected = rows.findIndex((row) => row.kind === "action" && row.item.id === activeId);
const activeIndex =
rows[clamped]?.kind === "action"
? clamped
: firstEnabled >= 0
? firstEnabled
: firstSelectable(rows, isListSection);
selected >= 0 ? selected : firstEnabled >= 0 ? firstEnabled : firstSelectable(rows, isListSection);
const activeRow = rows[activeIndex];
const activeItem = activeRow?.kind === "action" ? activeRow.item : undefined;
const showIcons = !popup.compact || popup.items.some((item) => item.icon || item.symbol);
@@ -183,11 +179,11 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
if (item) activate(item);
} else if (e.key === "Backspace" && query) {
setQuery(query.slice(0, -1));
setActive(-1);
setActiveId(null);
e.preventDefault();
} else if (e.key.length === 1 && !(e.key === " " && !query)) {
setQuery(query + e.key);
setActive(-1);
setActiveId(null);
e.preventDefault();
}
};
@@ -297,7 +293,10 @@ function ListPopup({ popup }: { popup: Extract<LspPopup, { kind: "list" }> }) {
row.kind === "section" && row.label ? <T>{row.label}</T> : <span className={styles.listDivider} />
}
activeIndex={activeIndex}
onActiveChange={setActive}
onActiveChange={(index) => {
const row = rows[index];
setActiveId(row?.kind === "action" ? row.item.id : null);
}}
hoverSelects
autoFocus
aria-label={popup.title}
@@ -762,25 +761,34 @@ function PreviewDialog({ popup }: { popup: Extract<LspPopup, { kind: "preview" }
</ul>
) : (
<ul data-testid="refactor-preview" className={styles.previewList} aria-label={tx("Changes")}>
{summary.entries.map((e) => (
<li key={e.path} className={styles.previewRow}>
<Icon name={fileIconName(basename(e.path), e.path)} size={14} className={styles.itemIcon} />
<span className={styles.previewName} title={relativePath(root, e.path)}>
{basename(e.path)}
</span>
<span className={styles.previewPath} title={relativePath(root, e.path)}>
{relativePath(root, e.path)}
</span>
<span className={styles.spacer} />
{e.operation === "rename" && e.to && <span className={styles.previewOp}>→ {basename(e.to)}</span>}
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
{e.edits > 0 && (
<span className={styles.previewCount}>
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
{summary.entries.map((e) => {
const name = basename(e.path);
const directory = relativeDir(root, e.path);
return (
<li key={e.path} className={styles.previewRow}>
<Icon name={fileIconName(name, e.path)} size={14} className={styles.itemIcon} />
<span className={styles.previewFile} title={relativePath(root, e.path)}>
<span className={styles.previewName}>{name}</span>
{directory && (
<span className={styles.previewDirectory}>
<bdi>{directory}</bdi>
</span>
)}
</span>
)}
</li>
))}
{e.operation === "rename" && e.to && (
<span className={styles.previewOp} title={relativePath(root, e.to)}>
→ {basename(e.to)}
</span>
)}
{e.operation && e.operation !== "rename" && <span className={styles.previewOp}>{e.operation}</span>}
{e.edits > 0 && (
<span className={styles.previewCount}>
{e.edits} {e.edits === 1 ? "occurrence" : "occurrences"}
</span>
)}
</li>
);
})}
</ul>
)}
</Dialog>
+10 -2
View File
@@ -60,11 +60,18 @@ export function quickFixIcon(view: EditorView): "bulb" | "bulb-fix" {
const isFixItem = (item: ListPopupItem) => item.quickFix ?? item.icon === "bulb-fix";
/** Local and language-server fixes share icons and the same stable ordering. */
/** Local and language-server fixes share icons and are grouped separately from other actions. */
export function listedIntentions(view: EditorView, items: ListPopupItem[]): ListPopupItem[] {
const rank = (item: ListPopupItem) => (item.disabled ? 4 : 0) + (isFixItem(item) ? 0 : 2) + (item.emphasis ? 0 : 1);
return items
.map((item) => (isFixItem(item) ? { ...item, quickFix: true, icon: quickFixIcon(view) } : item))
.map((item) => {
const fix = isFixItem(item);
return {
...item,
...(fix && { quickFix: true, icon: quickFixIcon(view) }),
section: item.section ?? { id: item.disabled ? "unavailable" : fix ? "quick-fixes" : "intentions" },
};
})
.sort((a, b) => rank(a) - rank(b));
}
@@ -497,6 +504,7 @@ export function withInspectionControls(view: EditorView, items: ListPopupItem[])
...inspections.map((inspection) => ({
id: `inspection:${inspection.id}`,
label: tx`Inspection '${txPart(inspection.name)}' options`,
section: { id: "inspection-options" },
icon: "settings",
run: () => editInspectionSettings(inspection.id),
submenu: intentionControls(inspection),
@@ -94,10 +94,16 @@
flex: none;
color: var(--fg-muted);
}
.fileName {
.fileName,
.directory {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.directory {
flex: 0 2 auto;
color: var(--fg-subtle);
}
.line {
overflow: hidden;
text-align: right;
+12 -5
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 } from "@/editor/api";
import { codePreviewExtensions, disambiguateTitles } from "@/editor/api";
import { basename } from "@/platform/project";
import { shortcutLabel } from "@/platform/keymap";
import { Icon, IconButton, List, Popup, Select, Spinner, fileIconName, listNavigate } from "@/ui";
@@ -86,6 +86,14 @@ function UsagesPopupInner() {
const preview = useUsagesPopupPreview((s) => s.preview);
const rowHeight = useRowHeight(ROW);
const all = useMemo<Usage[]>(() => groups.flatMap((g) => g.usages), [groups]);
const directories = useMemo(
() =>
disambiguateTitles(
groups.map((g) => g.path),
basename,
),
[groups],
);
const [filter, setFilter] = useState("");
const accessOptions = useUsageAccessOptions();
const items = useMemo(
@@ -233,11 +241,10 @@ function UsagesPopupInner() {
}
renderItem={(u) => (
<div className={styles.row} data-testid="usage-row" data-path={u.path} data-line={u.line}>
<span className={styles.file}>
<span className={styles.file} title={u.path}>
<Icon name={fileIconName(basename(u.path), u.path)} size={16} className={styles.icon} />
<span className={styles.fileName} title={u.path}>
{basename(u.path)}
</span>
<span className={styles.fileName}>{basename(u.path)}</span>
{directories.has(u.path) && <span className={styles.directory}>{directories.get(u.path)}</span>}
</span>
<span className={styles.line}>{u.line + 1}</span>
<UsagePreview usage={u} />
@@ -55,7 +55,8 @@
display: flex;
align-items: center;
gap: var(--space-1);
min-width: min(8ch, 45%);
/* Cap the automatic flex minimum at the space needed for a short preview. */
width: min(14ch, 50%);
flex: 1 1 0;
}
@@ -135,9 +136,8 @@
}
.type {
min-width: 0;
max-width: 25%;
flex: 0 1 auto;
min-width: min(3ch, 10%);
flex: 0 4 auto;
overflow: hidden;
text-overflow: ellipsis;
color: var(--fg-subtle);
@@ -159,11 +159,17 @@
font-size: var(--fs-ui);
}
.editRow,
.editRow > .valueGroup {
height: 100%;
}
.editInput {
flex: 1;
min-width: min(80px, 40%);
height: 18px;
padding: 0 4px;
box-sizing: border-box;
flex: 1 1 0;
min-width: 0;
height: calc(100% - var(--space-1));
padding: 0 var(--space-1);
font: inherit;
font-family: var(--font-mono);
color: var(--fg-strong);
@@ -176,6 +182,10 @@
border-color: var(--danger);
}
.editError {
max-width: 33%;
}
/* Changed since the previous stop. */
.name.changed {
color: var(--debug-changed, var(--link));
+58 -48
View File
@@ -467,6 +467,7 @@ export function VariablesView({
editing?.key === n.key ? (
<VarEditRow
node={n}
changed={isChanged(n)}
value={editing.value}
error={editing.error}
onChange={(value) => setEditing({ ...editing, value, error: null })}
@@ -558,6 +559,7 @@ function ValueDialog({
function VarEditRow({
node,
changed,
value,
error,
onChange,
@@ -565,6 +567,7 @@ function VarEditRow({
onCancel,
}: {
node: VarNode;
changed: boolean;
value: string;
error: string | null;
onChange: (v: string) => void;
@@ -575,37 +578,36 @@ function VarEditRow({
// the global "Escape → focus editor" binding (`!popupOpen`) from firing.
useEffect(() => acquirePopup(), []);
return (
<span className={styles.row}>
<span className={styles.name} title={node.name}>
{node.name}
<span className={clsx(styles.row, styles.editRow)} title={node.name}>
<VarPrefix node={node} changed={changed} />
<span className={styles.valueGroup}>
<input
className={clsx(styles.editInput, error && styles.editInvalid)}
value={value}
autoFocus
spellCheck={false}
autoComplete="off"
aria-label={`New value of ${node.name}`}
aria-invalid={!!error || undefined}
title={error ?? undefined}
onFocus={(e) => e.currentTarget.select()}
onChange={(e) => onChange(e.target.value)}
onClick={(e) => e.stopPropagation()}
onDoubleClick={(e) => e.stopPropagation()}
onBlur={onCancel}
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter") {
e.preventDefault();
onCommit();
} else if (e.key === "Escape") {
e.preventDefault();
onCancel();
}
}}
/>
{error && <span className={clsx(styles.error, styles.editError)}>{oneLine(error)}</span>}
</span>
<span className={styles.eq}>=</span>
<input
className={clsx(styles.editInput, error && styles.editInvalid)}
value={value}
autoFocus
spellCheck={false}
autoComplete="off"
aria-label={`New value of ${node.name}`}
aria-invalid={!!error || undefined}
title={error ?? undefined}
onFocus={(e) => e.currentTarget.select()}
onChange={(e) => onChange(e.target.value)}
onClick={(e) => e.stopPropagation()}
onDoubleClick={(e) => e.stopPropagation()}
onBlur={onCancel}
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter") {
e.preventDefault();
onCommit();
} else if (e.key === "Escape") {
e.preventDefault();
onCancel();
}
}}
/>
{error && <span className={styles.error}>{error}</span>}
</span>
);
}
@@ -616,6 +618,31 @@ function nodeIcon(node: VarNode): string {
return node.depth0 ? "variable" : "field";
}
function VarPrefix({ node, changed, showName = true }: { node: VarNode; changed: boolean; showName?: boolean }) {
const evaluation = node.kind === "eval";
return (
<>
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
{showName && (
<>
<span
className={clsx(
styles.name,
evaluation && styles.evalName,
node.kind === "var" && styles.varName,
changed && styles.changed,
)}
title={evaluation ? node.name : undefined}
>
{evaluation ? oneLine(node.name) : node.name}
</span>
<span className={styles.eq}>=</span>
</>
)}
</>
);
}
function VarRow({
node,
changed,
@@ -655,26 +682,9 @@ function VarRow({
);
const kind = node.error ? null : classifyValue(node.value, node.typeName);
const shown = shownValue(node.value, node.typeName);
const evaluation = node.kind === "eval";
return (
<span className={styles.row} title={node.name}>
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
{!shown.entry && (
<>
<span
className={clsx(
styles.name,
evaluation && styles.evalName,
node.kind === "var" && styles.varName,
changed && styles.changed,
)}
title={evaluation ? node.name : undefined}
>
{evaluation ? oneLine(node.name) : node.name}
</span>
<span className={styles.eq}>=</span>
</>
)}
<VarPrefix node={node} changed={changed} showName={!shown.entry} />
{node.error ? (
<span className={styles.error}>{oneLine(node.error)}</span>
) : (
+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>
);
+15 -6
View File
@@ -143,7 +143,10 @@ export function foldRows(
const fold: Fold = { start: i, count: j - i, id: lines[i]!.id, expanded: expanded.has(lines[i]!.id) };
const prev = rows[rows.length - 1];
if (prev?.kind === "line") prev.fold = fold;
else if (!fold.expanded) rows.push({ kind: "fold", fold });
else if (fold.expanded) {
rows.push({ kind: "line", index: i, fold });
i++;
} else rows.push({ kind: "fold", fold });
if (fold.expanded) for (; i < j; i++) rows.push({ kind: "line", index: i });
i = j;
continue;
@@ -230,7 +233,7 @@ export function ConsoleView({
// Pending input continues the open line (a prompt), or starts a row of its own.
const lastRow = folded[folded.length - 1];
const inputInline =
!!input && !!model.openLine && lastRow?.kind === "line" && !lastRow.fold && lines[lastRow.index] === model.openLine;
!!input && !!model.openLine && lastRow?.kind === "line" && lines[lastRow.index] === model.openLine;
const inputRow = !!input && !inputInline;
const [widest] = useState(() => new WidestColumns());
// eslint-disable-next-line react-hooks/exhaustive-deps -- `version` marks in-place appends to `lines`
@@ -255,7 +258,7 @@ export function ConsoleView({
getItemKey: (i) => {
const r = rows[i];
if (!r) return "input";
return r.kind === "fold" ? `f${r.fold.id}` : (lines[r.index]?.id ?? i);
return r.kind === "fold" ? r.fold.id : (lines[r.index]?.id ?? i);
},
});
@@ -486,7 +489,7 @@ export function ConsoleView({
return;
}
if (copySelectionOnKeyDown(e, selectedOutput)) return;
if (!input) return;
if (!input || e.target instanceof HTMLButtonElement) return;
if (e.key === "d" && e.ctrlKey && !e.metaKey && !e.altKey) {
e.preventDefault();
input.onEof();
@@ -523,19 +526,24 @@ export function ConsoleView({
const foldButton = (fold: Fold, attached: boolean) =>
fold.expanded ? (
<button
key={fold.id}
type="button"
className={styles.foldToggle}
style={{ height: rowHeight }}
title={tx("Collapse folded lines")}
aria-label={tx("Collapse folded lines")}
aria-expanded={true}
onClick={() => toggleFold(fold.id)}
>
<Icon name="chevron-up" size={10} />
<Icon name="chevron-down" size={10} />
</button>
) : (
<button
key={fold.id}
type="button"
className={styles.fold}
title={tx("Expand folded lines")}
aria-expanded={false}
onClick={() => toggleFold(fold.id)}
>
{`${attached ? " " : ""}${fold.count === 1 ? tx`<${fold.count} internal line>` : tx`<${fold.count} internal lines>`}`}
@@ -651,6 +659,7 @@ export function ConsoleView({
className={clsx(styles.line, styles[line.kind])}
style={{ ...rowStyle(item.start), color, background: ruled?.line?.bg }}
>
{row.fold?.expanded && foldButton(row.fold, false)}
<Line
line={line}
marks={marksByLine.get(row.index)}
@@ -658,7 +667,7 @@ export function ConsoleView({
length={line.text.length}
cwd={cwd}
/>
{row.fold && foldButton(row.fold, true)}
{row.fold && !row.fold.expanded && foldButton(row.fold, true)}
{inputInline && item.index === rows.length - 1 && pendingInput}
{"\n"}
</div>
+51 -22
View File
@@ -212,7 +212,7 @@
top: 0;
left: 0;
min-width: 100%;
padding: 0 12px;
padding: 0 var(--space-3);
line-height: inherit;
white-space: pre;
tab-size: 4;
@@ -258,12 +258,12 @@
.testStatusBar {
flex: none;
display: flex;
flex-wrap: wrap;
align-items: center;
min-height: 28px;
border-bottom: 1px solid var(--border);
}
.testToolbar {
flex-wrap: wrap;
gap: var(--space-1);
padding: var(--space-0-5) var(--space-1);
}
@@ -275,27 +275,36 @@
border-inline-end: 1px solid var(--border);
}
.testStatusBar {
gap: var(--space-0-5) var(--space-2);
gap: var(--space-2);
padding: var(--space-0-5) var(--space-2);
border-block-end-width: var(--space-0-5);
font-size: var(--fs-ui);
color: var(--fg-secondary);
}
.testStatusBar[data-outcome="passed"] {
border-block-end-color: var(--success);
}
.testStatusBar[data-outcome="skipped"] {
border-block-end-color: var(--warning);
}
.testStatusBar[data-running] {
border-block-end-color: var(--accent);
}
.testStatusBar[data-outcome="failed"] {
border-block-end-color: var(--danger);
}
.testCounts {
flex: 1 1 auto;
display: flex;
flex-wrap: wrap;
gap: var(--space-0-5) var(--space-2);
min-width: 0;
white-space: nowrap;
}
.testStatus,
.testTotalDuration {
.testStatus {
flex: none;
}
.testTotalDuration {
margin-left: auto;
color: var(--fg-subtle);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.testTree {
@@ -665,22 +674,39 @@
gap: var(--space-2);
}
.configFields {
flex: 1;
min-height: 0;
display: grid;
grid-template-columns: fit-content(40%) minmax(0, 1fr);
grid-template-rows: [notice] auto [header] auto [options] minmax(0, 1fr);
column-gap: var(--space-3);
row-gap: var(--space-2);
align-content: start;
min-width: 0;
}
.configFields > * {
.configFields > *,
.formSettings > * {
grid-column: 1 / -1;
min-width: 0;
}
.configFields:not(.configFieldsTomcat) > .field,
.configFields > .notice {
grid-row: notice;
}
.configFields:not(.configFieldsTomcat) > .notice,
.configFields:not(.configFieldsTomcat) > .formHeader {
margin-bottom: var(--space-2);
}
.configFields:not(.configFieldsTomcat) > .formHeader,
.configFields:not(.configFieldsTomcat) > .formHeader > .field {
.configFields:not(.configFieldsTomcat) > .formHeader > .field,
.formSettings > .field {
grid-template-columns: subgrid;
}
.formSettings {
display: grid;
grid-row: options;
grid-template-columns: subgrid;
row-gap: var(--space-2);
align-content: start;
overflow: auto;
}
.formHeader > .field {
grid-column: 1 / -1;
}
@@ -688,8 +714,6 @@
overflow: hidden;
}
.configFieldsTomcat {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
gap: var(--space-2);
@@ -793,6 +817,7 @@
}
.formHeader {
display: grid;
grid-row: header;
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: var(--space-4);
@@ -1118,15 +1143,19 @@
color: var(--fg);
}
.foldToggle {
display: inline-flex;
align-items: center;
margin-left: 6px;
padding: 0 2px;
position: sticky;
inset-inline-start: 0;
z-index: 1;
display: inline-grid;
place-items: center;
width: var(--space-3);
margin-inline-start: calc(-1 * var(--space-3));
padding: 0;
border: none;
border-radius: 3px;
background: none;
border-radius: var(--radius-small);
background: var(--bg-app);
color: var(--fg-faint);
vertical-align: middle;
vertical-align: top;
cursor: pointer;
}
.foldToggle:hover {
+10 -13
View File
@@ -112,27 +112,24 @@ export function TestStatusBar({
running: boolean;
}) {
const counts = useMemo(() => results.counts(), [results, version]); // eslint-disable-line react-hooks/exhaustive-deps
const status = running
? "running"
: counts.failed
? "failed"
: counts.passed
? "passed"
: counts.skipped
? "skipped"
: null;
const outcome = counts.failed ? "failed" : counts.passed ? "passed" : counts.skipped ? "skipped" : null;
const duration = results.summary.durationMs;
return (
<div className={styles.testStatusBar} role="status">
<StatusIcon status={status} />
<div
className={styles.testStatusBar}
role="status"
data-running={running || undefined}
data-outcome={outcome ?? undefined}
>
<StatusIcon status={running ? "running" : outcome} />
<span className={styles.testCounts}>
{counts.failed > 0 && <span className={styles.failed}>{tx`${counts.failed} failing`}</span>}
{counts.passed > 0 && <span>{tx`${counts.passed} passed`}</span>}
{counts.skipped > 0 && <span className={styles.skipped}>{tx`${counts.skipped} ignored`}</span>}
{counts.total === 0 && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
{!outcome && <span className={styles.skipped}>{running ? tx("Running…") : tx("No tests")}</span>}
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
</span>
{duration !== undefined && <span className={styles.testTotalDuration}>{formatDuration(duration)}</span>}
</div>
);
}
+33 -26
View File
@@ -15,6 +15,7 @@ import { call, commands, type OutlineItem } from "@/platform/ipc";
import { monoFontFamily } from "@/platform/fonts";
import { shortcutLabel } from "@/platform/keymap";
import { useProject } from "@/platform/project";
import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
import {
Checkbox,
Dialog,
@@ -40,7 +41,7 @@ import {
type ToolWindowContribution,
} from "@/workbench/contributions";
import { highlightTokens, languageForPath, type CodeToken } from "@/editor/lsp/markdown";
import { basename, openInListOrder, openLocation } from "../common/open";
import { basename, openInListOrder, openLocation, relDir } from "../common/open";
import { outlinePathAt } from "../structure/outline";
import { fromNavigationHistory, isDismissed, mergeLocations, type RecentLocation } from "../common/locations";
import { dismissLocation, useTracking } from "../common/tracking";
@@ -688,33 +689,39 @@ function RecentLocationsDialog() {
rowHeight={rowHeight}
aria-label="Recent locations"
empty={<span>{changedOnly ? tx("No changed locations") : tx("No recent locations")}</span>}
renderItem={(l) => (
<div className={styles.location}>
<div className={styles.locationHeader}>
<Icon name={fileIconName(basename(l.rel), l.rel)} size={14} className={styles.icon} />
<HighlightedText
className={clsx(styles.name, styles.locationName)}
text={basename(l.rel)}
indices={l.nameIndices}
tone="strong"
renderItem={(l) => {
const name = basename(l.rel);
const breadcrumb = breadcrumbOf(outlines.get(l.path), l);
const directory = isVirtualUri(l.path) ? virtualContainer(l.path) : relDir(l.rel);
const context = breadcrumb && breadcrumb !== name ? breadcrumb : directory;
return (
<div className={styles.location}>
<div className={styles.locationHeader} title={l.rel}>
<Icon name={fileIconName(name, l.rel)} size={14} className={styles.icon} />
<HighlightedText
className={clsx(styles.name, styles.locationName)}
text={name}
indices={l.nameIndices}
tone="strong"
/>
{context && <span className={styles.dir}>{context}</span>}
{l.changed && (
<span className={styles.changed}>
<T>changed</T>
</span>
)}
<span className={styles.time}>{locationTime(l.time, now)}</span>
</div>
<SnippetCode
path={l.path}
lines={dedent(l.snippet)}
first={l.snippetStart}
caret={l.line}
style={snippetStyle}
/>
<span className={styles.dir}>{breadcrumbOf(outlines.get(l.path), l) || l.rel}</span>
{l.changed && (
<span className={styles.changed}>
<T>changed</T>
</span>
)}
<span className={styles.time}>{locationTime(l.time, now)}</span>
</div>
<SnippetCode
path={l.path}
lines={dedent(l.snippet)}
first={l.snippetStart}
caret={l.line}
style={snippetStyle}
/>
</div>
)}
);
}}
/>
</div>
</Dialog>
@@ -101,19 +101,28 @@
color: var(--fg-strong);
font-weight: 600;
}
.crumb:last-child {
.parentCrumbs {
display: flex;
min-width: 0;
}
.crumb > span {
overflow: hidden;
text-overflow: ellipsis;
}
.crumb {
display: inline-flex;
align-items: center;
min-width: 0;
}
.crumbLabel {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.currentCrumb {
flex: none;
max-width: 100%;
}
.crumbSep {
margin: 0 4px;
flex: none;
margin-inline: var(--space-1);
color: var(--fg-subtle);
}
.reset {
@@ -165,21 +165,29 @@ function PageHost({
const [headerSlot, setHeaderSlot] = useState<HTMLElement | null>(null);
if (!node) return <EmptyState title="Nothing found" icon="search" />;
const Body = page?.component;
const parents = crumbs.slice(0, -1);
return (
<PageContext.Provider value={ctx}>
<SettingsFormContext.Provider value={form}>
<SettingsPageFocusContext.Provider value={pageFocus}>
<SettingsHeaderSlotContext.Provider value={headerSlot}>
<div className={styles.pageHeader}>
<div className={styles.crumbs} aria-label={tx("Breadcrumb")}>
{crumbs.map((c, i) => (
<span key={i} className={styles.crumb}>
{i > 0 && <Icon name="chevron-right" size={12} className={styles.crumbSep} />}
<span>
<T>{c}</T>
</span>
<div className={styles.crumbs} aria-label={tx("Breadcrumb")} title={crumbs.map((c) => tx(c)).join(" › ")}>
{parents.length > 0 && (
<span className={styles.parentCrumbs}>
{parents.map((c, i) => (
<span key={i} className={styles.crumb}>
<span className={styles.crumbLabel}>
<T>{c}</T>
</span>
<Icon name="chevron-right" size={12} className={styles.crumbSep} />
</span>
))}
</span>
))}
)}
<span className={clsx(styles.crumbLabel, styles.currentCrumb)} aria-current="page">
<T>{node.title}</T>
</span>
</div>
<div ref={setHeaderSlot} className={styles.headerSlot} />
{dirty && (
+43
View File
@@ -0,0 +1,43 @@
import type { Commit } from "@/bindings";
import type { ReactNode } from "react";
import { fontWeightOf } from "@/platform/editorSettings";
import { resolveMonoFont } from "@/platform/fonts";
import { tx } from "@/platform/i18n";
import { useProject } from "@/platform/project";
import styles from "./GitLog.module.css";
export function CommitMessageContent({
commit,
message,
compact = false,
renderText = (text) => text,
revision = commit.shortId,
}: {
commit: Commit;
message: string;
compact?: boolean;
renderText?: (text: string) => ReactNode;
revision?: ReactNode;
}) {
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const [subject = "", ...bodyLines] = message.trimEnd().split("\n");
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
return (
<>
<div
className={styles.messageText}
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
>
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
{renderText(subject)}
</div>
{body && <div className={styles.fullMessage}>{renderText(body)}</div>}
</div>
<div className={styles.meta}>
{revision} {commit.author} &lt;{commit.email}&gt;
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
</div>
</>
);
}
+20 -1
View File
@@ -405,9 +405,12 @@
.subject {
flex: 0 1 auto;
min-width: var(--log-subject-min);
color: var(--fg);
}
.subjectText {
display: block;
overflow: hidden;
text-overflow: ellipsis;
color: var(--fg);
}
.headSubject {
font-weight: 600;
@@ -437,6 +440,22 @@
flex: none;
max-width: calc(100% - var(--log-subject-min) - var(--space-1-5));
}
.commitText > .refsCompact {
flex: 0 1 auto;
max-width: calc(100% / 3);
}
.commitText:has(> .refsCompact) > .subject {
/* Protect a short subject while leaving room for compact reference names. */
flex: 0 1000 max-content;
min-width: auto;
width: min(75%, 24ch);
}
.commitText > .refs .ref {
font-size: var(--fs-small);
}
.refsCompact .ref {
min-width: 11px;
}
.refsLeft {
margin-left: 0;
}
+2 -6
View File
@@ -10,6 +10,7 @@ import { executeAction } from "@/platform/actions";
import { call, commands } from "@/platform/ipc";
import { tx } from "@/platform/i18n";
import { Button, IconButton, Spinner, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
import { CommitMessageContent } from "./CommitMessageContent";
import { ComparisonTree } from "./ComparisonTree";
import { buildFileTree } from "./fileTree";
import { flatFileNodes, toLogChanges, type LogChange } from "./logChanges";
@@ -151,14 +152,9 @@ export function PushChanges({
/** The selected commit's full message, revision, author and time. */
function PushCommitDetails({ commit }: { commit: Commit }) {
const date = commit.timeMs ? new Date(commit.timeMs).toLocaleString() : null;
return (
<section className={styles.pushCommitDetails} aria-label={tx("Commit details")}>
<div className={styles.pushCommitMessage}>{commit.message.trimEnd() || commit.summary}</div>
<div className={styles.fileDir}>
{commit.shortId} {commit.author} &lt;{commit.email}&gt;
{date ? " " + tx`on ${date}` : ""}
</div>
<CommitMessageContent commit={commit} message={commit.message.trimEnd() || commit.summary} />
</section>
);
}
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from "vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import { fireEvent, render, screen, within } from "@testing-library/react";
import type { Commit } from "@/bindings";
const { files, combined, executeAction } = vi.hoisted(() => ({
@@ -69,8 +69,10 @@ describe("Push dialog changes", () => {
const one = { ...older, message: "Add order service\n\nIntroduces the service.\n", timeMs: 1_700_000_000_000 };
render(<PushChanges repo="/r" commits={[one]} />);
const details = screen.getByRole("region", { name: "Commit details" });
expect(details.textContent).toContain("Add order service\n\nIntroduces the service.");
expect(details.textContent).toContain("aaaaaaa me <[email protected]> on ");
const message = within(details);
expect(message.getByText("Add order service", { exact: true })).toBeTruthy();
expect(message.getByText("Introduces the service.", { exact: true })).toBeTruthy();
expect(message.getByText(/^aaaaaaa me <me@example\.com> on /)).toBeTruthy();
expect(await screen.findByText("src/orders")).toBeTruthy();
expect(screen.getAllByRole("treeitem")).toHaveLength(2);
const grouping = screen.getByRole("button", { name: "Group by Directory" });
-8
View File
@@ -363,9 +363,6 @@
.pushCommitDetails {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
gap: var(--space-1);
margin: var(--space-1) var(--space-3);
padding: var(--space-1) var(--space-2);
overflow: auto;
@@ -374,11 +371,6 @@
-webkit-user-select: text;
user-select: text;
}
.pushCommitMessage {
color: var(--fg-strong);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.todoList {
margin: 8px 0 0;
padding-left: 18px;
+18 -34
View File
@@ -1,10 +1,8 @@
import type { Commit } from "@/bindings";
import { writeClipboardText } from "@/platform/clipboard";
import { fontWeightOf } from "@/platform/editorSettings";
import { resolveMonoFont } from "@/platform/fonts";
import { tx } from "@/platform/i18n";
import { useProject } from "@/platform/project";
import clsx from "clsx";
import { CommitMessageContent } from "../CommitMessageContent";
import styles from "../GitLog.module.css";
import { IssueText } from "../issueLinks";
import { useCommitDetails } from "../logDetails";
@@ -37,7 +35,7 @@ export function RefLabels({
}) {
const labels = refLabels(refs, { compact, tagNames }, remoteNames);
return (
<span className={clsx(styles.refs, left && styles.refsLeft)}>
<span className={clsx(styles.refs, compact && styles.refsCompact, left && styles.refsLeft)}>
{labels.map((l) => (
<span key={`${l.kind}:${l.title}`} className={clsx(styles.ref, REF_KIND_CLASS[l.kind])} title={l.title}>
{l.text && <span className={styles.refText}>{l.text}</span>}
@@ -50,39 +48,25 @@ export function RefLabels({
/** A commit's message and metadata; `compact` (one of several selected): without the body. */
export function CommitMessage({ commit, compact = false }: { commit: Commit; compact?: boolean }) {
const { details, error } = useCommitDetails(commit, !compact);
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const repo = commitRepo(commit) ?? currentRepo();
const message = details?.message || commit.message;
const [subject, ...bodyLines] = message.replace(/\s+$/, "").split("\n");
const body = compact ? "" : bodyLines.join("\n").replace(/^\n+/, "");
return (
<div className={clsx(compact && styles.commitEntry)}>
<div
className={styles.messageText}
style={{ fontFamily: family, fontSize: size, fontWeight: fontWeightOf(editor?.fontWeight, 400) }}
>
<div className={styles.subjectLine} style={{ fontWeight: fontWeightOf(editor?.boldFontWeight, 700) }}>
<CommitMessageText text={subject ?? ""} repo={repo} />
</div>
{body && (
<div className={styles.fullMessage}>
<CommitMessageText text={body} repo={repo} />
</div>
)}
</div>
<div className={styles.meta}>
<button
type="button"
className={styles.linkButton}
title={tx("Copy revision number")}
onClick={() => void writeClipboardText(commit.id)}
>
{commit.shortId}
</button>{" "}
{commit.author} &lt;{commit.email}&gt;
{commit.timeMs ? " " + tx`on ${new Date(commit.timeMs).toLocaleString()}` : ""}
</div>
<CommitMessageContent
commit={commit}
message={details?.message || commit.message}
compact={compact}
renderText={(text) => <CommitMessageText text={text} repo={repo} />}
revision={
<button
type="button"
className={styles.linkButton}
title={tx("Copy revision number")}
onClick={() => void writeClipboardText(commit.id)}
>
{commit.shortId}
</button>
}
/>
{!compact &&
commit.committer &&
(commit.committer !== commit.author ||
+3 -1
View File
@@ -134,7 +134,9 @@ function CommitRowView({
setTooltip(false);
}}
>
<IssueText text={c.summary} />
<span className={styles.subjectText}>
<IssueText text={c.summary} />
</span>
</span>
{!opts.refsOnLeft && refs}
</span>