Compare commits

..
Author SHA1 Message Date
l0ng-ai 45b757e5d0 fix(vcs): keep commit check actions visible while reading results 2026-11-23 02:14:37 +08:00
135 changed files with 1097 additions and 4021 deletions

No files matched your search

+2 -15
View File
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
assert_eq!(b.pom, canonical);
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
assert_eq!(
@@ -63,26 +63,13 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
let gone = ops::build::build_model(&host, "main").await.unwrap();
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
assert!(host.project("main").unwrap().content_roots().is_empty());
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
assert_eq!(saved(), Vec::<String>::new());
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
host.shutdown().await;
}
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
/// the background.
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
for _ in 0..200 {
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
if ready(&roots) {
return roots;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
}
host.project("main").unwrap().lsp.jdtls_import_roots()
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
let temp = tempfile::tempdir().unwrap();
-52
View File
@@ -1,52 +0,0 @@
import type { EditorView } from "@codemirror/view";
import { expect, stubDesktop, test } from "./fixtures";
test("gutter breakpoint keeps its location and buttons visible while editing in a short window", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 410, height: 340 });
await stubDesktop(page);
const name = "RecalculateInternationalPaymentsAcrossMultipleRegionalSettlementCyclesAndVerifyReceiptTotals.ts";
const path = `/dev/acme-api/${name}`;
await page.evaluate(async (path) => {
const contributionsModule = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ contributionsModule);
await editorService().openFile(path);
}, path);
await page.locator(".cm-content").evaluate(async (editor, path) => {
const view = (editor as HTMLElement & { cmTile: { view: EditorView } }).cmTile.view;
const insert = Array.from({ length: 14 }, (_, i) => `const amount${i + 1} = ${i * 10};`).join("\n");
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert } });
const breakpointsModule = "/src/features/debugger/breakpoints/store.ts";
const { addBreakpoint } = await import(/* @vite-ignore */ breakpointsModule);
window.__ipc.handlers.debug_set_breakpoints = () => [];
addBreakpoint(path, 7, { condition: "amount8 > 50", hitCondition: ">= 3", logMessage: "amount: {amount8}" });
}, path);
const marker = page.locator(".cm-lineNumbers .cm-gutterElement").filter({ hasText: /^8$/ });
const open = () => marker.click({ button: "right" });
await open();
const popup = page.getByRole("dialog", { name: "Breakpoint properties" });
const done = popup.getByRole("button", { name: "Done", exact: true });
const condition = popup.getByLabel("Condition", { exact: true });
await expect(condition).toBeFocused();
await expect(done).toBeInViewport({ ratio: 1 });
const location = popup.getByTitle(`${path}:8`, { exact: true });
await expect(location.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 });
await expect(popup.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px");
await condition.fill("amount8 > 60");
const log = popup.getByRole("textbox", { name: "Evaluate and log", exact: true });
await log.fill("paid: {amount8}");
await expect(location).toBeInViewport({ ratio: 1 });
await expect(done).toBeInViewport({ ratio: 1 });
await done.click();
await expect(popup).toBeHidden();
await open();
await expect(condition).toHaveValue("amount8 > 60");
await expect(log).toHaveValue("paid: {amount8}");
await popup.getByRole("button", { name: /^More/ }).click();
const dialog = page.getByRole("dialog", { name: "Breakpoints", exact: true });
await expect(dialog.getByLabel("Condition", { exact: true })).toHaveValue("amount8 > 60");
});
+4 -26
View File
@@ -1,8 +1,8 @@
import type { Page } from "@playwright/test";
import { expect, test } from "./fixtures";
async function showBuild(page: Page, diagnosticPath: string | null = null) {
await page.evaluate(async (path) => {
async function showBuild(page: Page) {
await page.evaluate(async () => {
const storePath = "/src/features/build/store.ts";
const layoutPath = "/src/workbench/toolwindows/store.ts";
const { useBuildRun } = await import(/* @vite-ignore */ storePath);
@@ -17,10 +17,10 @@ async function showBuild(page: Page, diagnosticPath: string | null = null) {
{ kind: "out", text: "Compiling TypeScript" },
{ kind: "err", text: "Expected a number" },
],
messages: [{ severity: "error", text: "Expected a number", path, range: null, code: null }],
messages: [{ severity: "error", text: "Expected a number", path: null, range: null, code: null }],
});
showToolWindow("build", true);
}, diagnosticPath);
});
const build = page.getByRole("region", { name: "Build", exact: true });
await expect(build.getByRole("log", { name: "Build output" })).toBeVisible();
return build;
@@ -35,28 +35,6 @@ test("Build gives about two thirds of the initial split to output", async ({ wor
expect(treeWidth / (treeWidth + consoleWidth)).toBeCloseTo(0.33, 2);
});
test("Build reserves room for duration and file counts beside long directory paths", async ({ workbench: page }) => {
await page.setViewportSize({ width: 760, height: 680 });
const path = "/dev/acme-api/src/services/regional-catalogs/generated/api/development/builders/catalog.ts";
const build = await showBuild(page, path);
const root = build.getByRole("treeitem", { name: /^Build Project/ });
const filename = build.getByTitle(path, { exact: true }).getByText("catalog.ts", { exact: true });
const counts = build.getByTitle(path, { exact: true }).getByText("1 error", { exact: true });
const errorSummary = root.getByText("1 error", { exact: true });
const elapsed = root.getByText("1 s 200 ms", { exact: true });
await expect(elapsed).toHaveCSS("font-size", "12px");
await expect(counts).toBeInViewport({ ratio: 1 });
const textFits = (el: Element) => {
const range = document.createRange();
range.selectNodeContents(el);
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
};
expect(await filename.evaluate(textFits)).toBe(true);
expect(await errorSummary.evaluate(textFits)).toBe(true);
const [duration, row] = await Promise.all([elapsed.boundingBox(), root.boundingBox()]);
expect(row!.x + row!.width - duration!.x - duration!.width).toBeLessThan(12);
});
test("Build output and diagnostics respond to a console font change", async ({ workbench: page }) => {
const build = await showBuild(page);
const log = build.getByRole("log", { name: "Build output" });
-32
View File
@@ -111,7 +111,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
});
await expect(editor.locator(".cm-content")).toHaveCSS("font-size", zoomedSize);
await expect(method.locator(".cm-completionLabel")).toHaveCSS("font-size", zoomedSize);
await page.keyboard.type("toD");
await expect(popup.getByText("total", { exact: true })).toBeHidden();
// Refreshing the results rebuilds the list; the hint bar must stay below it, not jump to the top.
@@ -125,37 +124,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
await expect(popup).toBeHidden();
await expect(editor.locator(".cm-activeLine")).toHaveText(/^\s*order\.toDto\(\)$/);
expect((await ipcCalls(page, "lsp_completion")).length).toBeGreaterThan(0);
await page.evaluate(async () => {
const path = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ path)).executeAction("editor.splitRight");
});
const panes = page.locator("[data-pane-id]");
await expect(panes).toHaveCount(2);
await page.setViewportSize({ width: 480, height: 760 });
await panes.last().locator(".cm-content").focus();
await page.keyboard.press("End");
await page.keyboard.press("Enter");
await page.keyboard.type("order.");
await page.keyboard.press("Control+Space");
const footer = popup.locator(".cm-lsp-completion-footer");
await expect
.poll(() =>
footer.evaluate((el) => {
const tip = el.querySelector("span")!;
const sort = el.querySelector("button")!;
const a = tip.getBoundingClientRect();
const b = sort.getBoundingClientRect();
return {
oneRow: Math.abs(a.y + a.height / 2 - b.y - b.height / 2) <= 1,
hintClipped: tip.scrollWidth > tip.clientWidth,
sortFits: sort.scrollWidth <= sort.clientWidth + 1 && b.right <= el.getBoundingClientRect().right,
};
}),
)
.toEqual({ oneRow: true, hintClipped: true, sortFits: true });
await expect(footer.getByTitle("Press ↵ to insert, ⇥ to replace")).toHaveCSS("font-size", "12px");
await expect(footer.getByRole("button", { name: "Sort by name" })).toBeInViewport({ ratio: 1 });
});
test("long completion signatures fit the editor when the workbench is narrowed", async ({ workbench: page }) => {
-62
View File
@@ -1,62 +0,0 @@
import { expect, test } from "./fixtures";
test("the editor color picker fits recent colors and keeps its actions visible", async ({ workbench: page }) => {
await page.setViewportSize({ width: 980, height: 720 });
await page.evaluate(async () => {
const recent = Array.from({ length: 20 }, (_, i) => `#${((i + 1) * 314241).toString(16).padStart(6, "0")}ff`);
localStorage.setItem("openidea.colorPicker.recent.v1", JSON.stringify(recent));
const contributions = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ contributions);
await editorService().openFile("/dev/acme-api/theme.css");
});
const editor = page.locator(".cm-editor").first();
const contents = editor.locator(".cm-content");
await contents.click();
await page.keyboard.press("Meta+a");
await page.keyboard.insertText(".notice { color: #5a8fbd; }");
const swatch = editor.locator(".cm-openidea-gutter-colors").getByTitle("#5a8fbd", { exact: true });
const picker = page.getByRole("dialog", { name: "Color picker", exact: true });
const palette = picker.locator(".react-colorful__saturation");
const hex = picker.getByRole("textbox", { name: "Hexadecimal", exact: true });
const apply = picker.getByRole("button", { name: "Apply", exact: true });
const cancel = picker.getByRole("button", { name: "Cancel", exact: true });
const recent = picker.getByRole("group", { name: "Recent colors", exact: true }).getByRole("button");
await swatch.click();
await expect(hex).toHaveValue("5A8FBDFF");
expect((await picker.boundingBox())!.width).toBeLessThanOrEqual(308);
await expect(palette).toHaveCSS("height", "152px");
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await hex.fill("#ff0000");
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await page.keyboard.press("Escape");
await expect(picker).toBeHidden();
await page.setViewportSize({ width: 280, height: 315 });
await swatch.click();
await expect(recent).toHaveCount(20);
const swatchRows = await recent.evaluateAll((elements) => {
const rows: number[] = [];
for (const element of elements) {
const box = element.getBoundingClientRect();
if (!rows.includes(box.top)) rows.push(box.top);
const previous = element.previousElementSibling?.getBoundingClientRect();
if (previous?.top === box.top && previous.right > box.left) throw new Error("Color swatches overlap");
}
return rows.length;
});
expect(swatchRows).toBeGreaterThan(2);
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
await expect(apply).toBeInViewport({ ratio: 1 });
await expect(cancel).toBeInViewport({ ratio: 1 });
await hex.fill("#d27c54");
await cancel.click();
await expect(picker).toBeHidden();
await expect(contents).toContainText("#5a8fbd");
await swatch.click();
await hex.fill("#d27c54");
await apply.click();
await expect(picker).toBeHidden();
await expect(contents).toContainText("#d27c54");
});
+10 -148
View File
@@ -85,66 +85,6 @@ test("⌘K commits the checked changes with the typed message", async ({ workben
await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden();
});
test("commit options align author fields and keep the date editable in a narrow dialog", async ({
workbench: page,
}) => {
await stubRepository(page);
await page.setViewportSize({ width: 1040, height: 700 });
await page.keyboard.press("Meta+k");
const panel = page.getByRole("region", { name: "Commit", exact: true });
await panel.getByRole("button", { name: "Commit Options", exact: true }).click();
const popup = page.getByRole("dialog", { name: "Commit Options", exact: true });
const author = popup.getByRole("textbox", { name: "Author", exact: true });
const date = popup.getByLabel("Author date", { exact: true });
const clear = popup.getByRole("button", { name: "Clear author date", exact: true });
const name = "Regional Ledger Review <[email protected]>";
const time = "2024-06-04T13:20:21";
await author.fill(name);
await date.fill(time);
const authorBox = (await author.boundingBox())!;
const dateBox = (await date.boundingBox())!;
const dateLabel = (await popup.getByText("Author date", { exact: true }).boundingBox())!;
const clearBox = (await clear.boundingBox())!;
expect(authorBox.x).toBeCloseTo(dateBox.x, 0);
expect(dateLabel.y).toBeGreaterThanOrEqual(dateBox.y);
expect(dateLabel.y).toBeLessThan(dateBox.y + dateBox.height);
expect(clearBox.x + clearBox.width).toBeCloseTo(authorBox.x + authorBox.width, 0);
await expect(clear).toBeInViewport({ ratio: 1 });
await page.keyboard.press("Escape");
await expect(popup).toBeHidden();
await page.evaluate(async () => {
const projectModule = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { settings } = useProject.getState();
useProject.setState({
settings: { ...settings, vcs: { ...settings?.vcs, commit: { ...settings?.vcs?.commit, nonModal: false } } },
});
});
await page.setViewportSize({ width: 650, height: 650 });
await page.keyboard.press("Meta+k");
const dialog = page.getByRole("dialog", { name: "Commit Changes", exact: true });
const options = dialog.getByRole("group", { name: "Commit Options", exact: true });
const compactAuthor = options.getByRole("textbox", { name: "Author", exact: true });
const compactDate = options.getByLabel("Author date", { exact: true });
const compactClear = options.getByRole("button", { name: "Clear author date", exact: true });
await expect(compactAuthor).toHaveValue(name);
await expect(compactDate).toHaveValue(time);
const labelBox = (await options.getByText("Author:", { exact: true }).boundingBox())!;
const inputBox = (await compactAuthor.boundingBox())!;
expect(inputBox.x).toBeCloseTo(labelBox.x, 0);
expect(inputBox.y).toBeGreaterThanOrEqual(labelBox.y + labelBox.height);
const box = (await compactDate.boundingBox())!;
const buttonBox = (await compactClear.boundingBox())!;
expect(box.width).toBeCloseTo(inputBox.width, 0);
expect(buttonBox.y).toBeGreaterThanOrEqual(box.y + box.height);
expect(await options.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1);
await compactClear.click();
await expect(compactDate).toHaveValue("");
await expect(compactClear).toBeHidden();
await expect(compactAuthor).toHaveValue(name);
});
test("the Commit window gives its message preferred focus", async ({ workbench: page }) => {
await stubRepository(page);
const stripe = page.locator('[data-stripe-button="commit"]');
@@ -1159,51 +1099,27 @@ test("the Commit tool window restores the draft and author options for the inclu
await expect(message).toHaveValue("Default draft");
});
test("commit message history shows compact message previews above the editor", async ({ workbench: page }) => {
await page.emulateMedia({ reducedMotion: "reduce" });
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
await stubRepository(page);
await page.keyboard.press("Meta+k");
const message = page.getByRole("textbox", { name: "Commit message" });
await expect(message).toBeVisible();
await page.evaluate((root) => {
localStorage.setItem(
`openidea.vcs.commitMessages:${root}`,
JSON.stringify([
"Update inventory\n\nReview settlement totals",
"Update inventory\n\nReconcile export records",
...Array.from({ length: 7 }, (_, index) => `Earlier message ${index + 1}`),
]),
);
localStorage.setItem(`openidea.vcs.commitMessages:${root}`, JSON.stringify(["Previous commit message"]));
}, ROOT);
await message.fill("Draft");
const history = page.getByRole("button", { name: "Commit Message History" });
await history.click();
await page.getByRole("button", { name: "Commit Message History" }).click();
const menu = page.getByRole("menu", { name: "Recent commit messages" });
const row = menu.getByRole("menuitem", { name: /Update inventory.*Review settlement totals/ });
const row = menu.getByRole("menuitem", { name: "Previous commit message" });
await expect(row).toBeVisible();
const messageBox = (await message.boundingBox())!;
const menuBox = (await menu.locator("..").boundingBox())!;
const rowBox = (await row.boundingBox())!;
expect(messageBox.y - menuBox.y - menuBox.height).toBeCloseTo(3, 0);
expect(Math.abs(menuBox.x - messageBox.x)).toBeLessThan(2);
expect(menuBox.height).toBeLessThan(rowBox.height * 8);
await expect(row).toHaveCSS("font-family", await message.evaluate((el) => getComputedStyle(el).fontFamily));
await expect(row).toHaveCSS("font-size", await message.evaluate((el) => getComputedStyle(el).fontSize));
const messageBox = await message.boundingBox();
const menuBox = await menu.locator("..").boundingBox();
expect(messageBox).not.toBeNull();
expect(menuBox).not.toBeNull();
expect(menuBox!.y + menuBox!.height).toBeLessThan(messageBox!.y);
expect(Math.abs(menuBox!.x - messageBox!.x)).toBeLessThan(2);
await expect(row.locator("span")).toHaveCount(1);
await row.press("Escape");
await expect(menu).toBeHidden();
await expect(message).toHaveValue("Draft");
await history.click();
await row.press("Home");
await expect(row).toBeFocused();
await page.keyboard.press("ArrowDown");
const second = menu.getByRole("menuitem", { name: /Update inventory.*Reconcile export records/ });
await expect(second).toBeFocused();
await page.keyboard.press("Enter");
await expect(message).toHaveValue("Update inventory\n\nReconcile export records");
await expect(message).toBeFocused();
});
test("Amend shows the original author and warns when the committer differs", async ({ workbench: page }) => {
@@ -1314,60 +1230,6 @@ async function stubEarlierAmend(page: Page) {
});
}
test("Amend sizes the chooser for long subjects while keeping the last commit action distinct", async ({
workbench: page,
}) => {
await stubEarlierAmend(page);
const tip = "Record regional settlement adjustments across the quarterly audit and reconciliation reports";
const earlier = "Expand the warehouse reconciliation report with monthly ledger and inventory audit totals";
await page.evaluate(
({ tip, earlier }) => {
const handlers = window.__ipc.handlers;
const log = handlers.vcs_log!;
handlers.vcs_log = (args) =>
(log(args) as { id: string; summary: string; message: string }[]).map((commit) => {
const subject = commit.id === "1111111" ? tip : commit.id === "aaaaaaa" ? earlier : commit.summary;
return { ...commit, summary: subject, message: subject };
});
},
{ tip, earlier },
);
await page.setViewportSize({ width: 1040, height: 700 });
await page.keyboard.press("Meta+k");
const panel = page.getByRole("region", { name: "Commit", exact: true });
const choose = panel.getByRole("button", { name: "Choose Commit to Amend", exact: true });
await choose.click();
const list = page.getByRole("listbox", { name: "Choose Commit to Amend", exact: true });
const popup = list.locator("xpath=ancestor::*[@data-popup]");
const search = popup.getByRole("textbox", { name: "Search commits", exact: true });
const last = list.getByRole("option", { name: /^Amend Last Commit/ });
const previous = list.getByRole("option", { name: earlier, exact: true });
await expect(previous).toBeVisible();
const wide = (await popup.boundingBox())!;
expect(wide.width).toBeGreaterThan(360);
expect(wide.width).toBeLessThanOrEqual(522);
await expect(last.getByText("Amend Last Commit", { exact: true })).toHaveCSS("font-weight", "600");
await expect(last.getByText(tip, { exact: true })).toHaveAttribute("title", tip);
await expect(previous.getByText(earlier, { exact: true })).toHaveAttribute("title", earlier);
await page.setViewportSize({ width: 440, height: 520 });
await expect
.poll(async () => {
const box = (await popup.boundingBox())!;
return box.x >= 0 && box.x + box.width <= 440 && box.width < wide.width;
})
.toBe(true);
await expect(search).toBeFocused();
await search.fill("inventory audit");
await expect(previous).toBeVisible();
await search.press("Enter");
await expect(list).toBeHidden();
await page.setViewportSize({ width: 1040, height: 700 });
await page.keyboard.press("Meta+k");
await expect(panel.getByRole("textbox", { name: "Commit message" })).toHaveValue(earlier);
});
test("Amend can select an earlier commit before protected history", async ({ workbench: page }) => {
await stubEarlierAmend(page);
await page.keyboard.press("Meta+k");
-78
View File
@@ -3,7 +3,6 @@
* with its frames and variables, and stepping and resuming go back to the adapter. The adapter is
* stubbed at the IPC layer; `crates/ide-dap/tests` drives real ones.
*/
import type { JvmMemoryResult } from "../src/platform/ipc";
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
const ROOT = "/dev/acme-api";
@@ -115,83 +114,6 @@ test("stops at a breakpoint, shows frames and variables, steps and resumes", asy
await expect(debug.getByText("CreateOrderRequest(sku='A-1', qty=2)")).toBeHidden();
});
test("Memory gives class filtering the available toolbar width and exposes changed-only filtering", async ({
workbench: page,
}) => {
const rows = [
{ name: "OrderCache", instances: 64, deltaInstances: 12 },
{ name: "OrderRepository", instances: 16, deltaInstances: 0 },
].map((row) => ({ ...row, bytes: row.instances * 16, deltaBytes: null, module: null, ambiguous: false }));
const result: JvmMemoryResult = {
status: "ready",
snapshot: {
rows,
totalInstances: 80,
totalBytes: 1280,
javaVersion: "21",
takenWhileSuspended: true,
hasBaseline: true,
elapsedMs: 5,
source: "debugger",
},
};
await stubDesktop(page);
await page.evaluate(
async ({ result, id }) => {
const caps = { jvmMemory: true, jvmHeap: true };
window.__ipc.handlers.debug_capabilities = () => caps;
window.__ipc.handlers.debug_jvm_memory_classes = () => result;
const debugPath = "/src/features/debugger/state.ts";
const { adoptSession } = await import(/* @vite-ignore */ debugPath);
adoptSession(id, { adapter: "java-debug", name: "Billing Service", status: "paused", caps });
const dockPath = "/src/workbench/toolwindows/store.ts";
const layout = await import(/* @vite-ignore */ dockPath);
layout.moveToolWindow("debug", "bottom");
layout.setToolWindowSize("bottom", 300);
layout.showToolWindow("debug", true);
},
{ result, id: SESSION },
);
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Memory" }).click();
const toolbar = debug.getByRole("toolbar", { name: "Memory", exact: true });
const filter = toolbar.getByRole("textbox", { name: "Filter classes" });
const options = toolbar.getByRole("button", { name: "View Options" });
const grid = debug.getByRole("grid", { name: "Memory", exact: true });
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
expect((await filter.boundingBox())!.width).toBeGreaterThan((await toolbar.boundingBox())!.width / 2);
await page.evaluate(async () => {
const dockPath = "/src/workbench/toolwindows/store.ts";
const layout = await import(/* @vite-ignore */ dockPath);
layout.moveToolWindow("debug", "right");
layout.setToolWindowSize("right", 330);
});
await expect.poll(async () => (await toolbar.boundingBox())!.width).toBeCloseTo(330, 0);
const bar = (await toolbar.boundingBox())!;
const gear = (await options.boundingBox())!;
const input = (await filter.boundingBox())!;
expect(input.width).toBeGreaterThan(bar.width / 2);
expect(input.x + input.width).toBeLessThan(gear.x);
expect(gear.x + gear.width).toBeLessThanOrEqual(bar.x + bar.width);
await filter.fill("cache");
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
await toolbar.getByRole("button", { name: "Clear", exact: true }).click();
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
await options.press("Enter");
const changed = page.getByRole("menuitemcheckbox", { name: "Changed only" });
await expect(changed).not.toBeChecked();
await changed.press("Enter");
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
await expect(options).toHaveAttribute("aria-pressed", "true");
await expect(options).toBeFocused();
await options.press("Enter");
await expect(changed).toBeChecked();
});
test("Evaluate keeps a multiline expression and its result visible in a short dialog", async ({ workbench: page }) => {
await page.setViewportSize({ width: 580, height: 420 });
await stubDesktop(page);
-37
View File
@@ -88,40 +88,3 @@ test("a close button on the left keeps a narrow slot before the icon", async ({
const slot = await box(closeOf(selected));
expect(slot.x + slot.width).toBeLessThanOrEqual(label.x + 0.5);
});
test("a pinned editor tab uses the close slot and can be unpinned from it", async ({ workbench: page }) => {
await openFromTree(page, "README.md");
await openFromTree(page, "build.gradle.kts");
const strip = page.getByRole("tablist", { name: "Editor tabs" });
const unpinned = strip.getByRole("tab", { name: "build.gradle.kts", exact: true });
const pinned = strip.getByRole("tab", { name: "build.gradle.kts Pinned", exact: true });
const menu = page.getByRole("menu", { name: "Context menu" });
const pin = async () => {
await unpinned.click({ button: "right" });
await menu.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
};
await pin();
const unpin = pinned.locator("..").getByRole("button", { name: "Unpin Tab", exact: true });
for (const closeButtonPosition of ["right", "left"]) {
await setTabs(page, { closeButtonPosition });
await expect(closeOf(pinned)).toHaveCount(0);
const tab = await box(pinned.locator(".."));
const action = await box(unpin);
const label = await box(pinned.locator(":scope > span"));
const inset = closeButtonPosition === "left" ? action.x - tab.x : tab.x + tab.width - action.x - action.width;
expect(inset).toBeCloseTo(2, 0);
expect(action.width).toBeCloseTo(16, 0);
if (closeButtonPosition === "left") expect(action.x + action.width).toBeLessThanOrEqual(label.x);
else expect(action.x).toBeGreaterThanOrEqual(label.x + label.width);
}
await setTabs(page, { showCloseButton: false });
await unpin.click();
await expect(unpinned).toHaveAttribute("aria-selected", "true");
await expect(closeOf(unpinned)).toHaveCount(0);
await pin();
await pinned.click({ button: "middle" });
await expect(pinned).toHaveCount(0);
});
-80
View File
@@ -1,80 +0,0 @@
import { expect, test } from "./fixtures";
const root = "/dev/acme-api";
const stem = "InternationalSettlementRegionalReconciliationAndAuditWarehouseAllocationConfiguration";
const original = stem + ".txt";
const renamed = "WarehouseAllocation.txt";
test("file rename groups the name and reflows the options without losing validation", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1000, height: 700 });
await page.evaluate(
async ({ root, original }) => {
const fsModule = "/src/features/project-tree/fs.ts";
const storeModule = "/src/features/project-tree/store.ts";
const { projectFs } = await import(/* @vite-ignore */ fsModule);
const { loadDir } = await import(/* @vite-ignore */ storeModule);
await projectFs(root).createFile(root + "/" + original);
await loadDir(root, true);
},
{ root, original },
);
const source = page.getByRole("treeitem", { name: original, exact: true });
await source.click();
await page.keyboard.press("Shift+F6");
const dialog = page.getByRole("dialog", { name: "Rename", exact: true });
const prompt = dialog.getByText("Rename file '" + original + "' and its usages to:", { exact: true });
const field = dialog.getByRole("textbox", { name: "New name" });
const references = dialog.getByRole("checkbox", { name: "Search for references" });
const comments = dialog.getByRole("checkbox", { name: "Search in comments and strings" });
const submit = dialog.getByRole("button", { name: "Refactor", exact: true });
const referencesRow = references.locator("xpath=ancestor::label");
const commentsRow = comments.locator("xpath=ancestor::label");
await expect(field).toBeFocused();
const selected = await field.evaluate((el: HTMLInputElement) => el.value.slice(el.selectionStart!, el.selectionEnd!));
expect(selected).toBe(stem);
await expect
.poll(async () => {
const a = (await prompt.boundingBox())!;
const b = (await field.boundingBox())!;
return b.y - a.y - a.height;
})
.toBeCloseTo(4, 0);
await expect
.poll(async () => {
const a = (await referencesRow.boundingBox())!;
const b = (await commentsRow.boundingBox())!;
return Math.abs(a.y - b.y) < 1 && b.x >= a.x + a.width;
})
.toBe(true);
await field.fill("README.md");
await expect(dialog.getByRole("alert")).toBeVisible();
await expect(submit).toBeDisabled();
await page.setViewportSize({ width: 400, height: 520 });
await expect
.poll(async () => {
const a = (await referencesRow.boundingBox())!;
const b = (await commentsRow.boundingBox())!;
return b.y >= a.y + a.height;
})
.toBe(true);
await expect(field).toHaveValue("README.md");
await expect(prompt).toBeInViewport({ ratio: 1 });
await expect(submit).toBeInViewport({ ratio: 1 });
expect(
await dialog.locator("[data-dialog-body]").evaluate((node) => node.scrollWidth - node.clientWidth),
).toBeLessThanOrEqual(1);
await field.fill(renamed);
await expect(dialog.getByRole("alert")).toBeHidden();
await references.uncheck();
await comments.uncheck();
await submit.click();
await expect(dialog).toBeHidden();
await page.setViewportSize({ width: 1000, height: 700 });
await expect(page.getByRole("treeitem", { name: renamed, exact: true })).toBeVisible();
await expect(source).toHaveCount(0);
});
-78
View File
@@ -1,78 +0,0 @@
import type { Locator, Page } from "@playwright/test";
import { expect, openFromTree, test } from "./fixtures";
const latest = "regional-order-reconciliation-endpoints-for-sandbox-environments/".repeat(3) + "checkout\nText to find";
async function seedHistory(page: Page, kind: "find" | "replace") {
await page.evaluate(
async ({ kind, latest }) => {
const searchModule = "/src/platform/search.ts";
const { rememberSearch } = await import(/* @vite-ignore */ searchModule);
for (let i = 0; i < 19; i++) rememberSearch(kind, `Order rule ${i}`);
rememberSearch(kind, latest);
},
{ kind, latest },
);
}
async function openHistory(field: Locator, menu: Locator) {
await field.focus();
await field.press("Alt+ArrowDown");
await expect(menu).toBeVisible();
}
test("editor find history grows with the field and restores the original query", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1040, height: 700 });
await openFromTree(page, "build.gradle.kts");
await page.keyboard.press("Meta+f");
await seedHistory(page, "find");
const field = page.getByRole("textbox", { name: "Find", exact: true });
const menu = page.getByRole("menu", { name: "Recent Searches", exact: true });
await openHistory(field, menu);
const newest = menu.getByRole("menuitem").first();
await expect(newest).toHaveText(latest.replace("\n", " ⏎ "));
await expect(newest).toHaveAttribute("title", latest);
await expect.poll(async () => (await menu.boundingBox())!.width).toBeGreaterThan(420);
await newest.press("Enter");
await expect(menu).toBeHidden();
await expect(field).toHaveValue(latest);
await expect(field).toBeFocused();
});
test("project replacement history stays inside a narrow window and keeps its heading visible", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 440, height: 520 });
await page.keyboard.press("Meta+Shift+r");
await seedHistory(page, "replace");
const field = page.getByRole("textbox", { name: "Replace with" });
const menu = page.getByRole("menu", { name: "Recent Replacements" });
await openHistory(field, menu);
const popup = menu.locator("..");
const heading = popup.getByText("Recent Replacements", { exact: true });
const newest = menu.getByRole("menuitem").first();
await expect(newest).toHaveText(latest.replace("\n", " ⏎ "));
await expect
.poll(async () => {
const { x, width } = (await popup.boundingBox())!;
return x >= 0 && x + width <= 440;
})
.toBe(true);
await newest.press("End");
const oldest = menu.getByRole("menuitem").last();
await expect(oldest).toBeFocused();
await expect.poll(async () => popup.evaluate((node) => node.scrollTop)).toBeGreaterThan(0);
await expect(heading).toBeInViewport();
await oldest.press("Home");
await expect(newest).toBeFocused();
await newest.press("Enter");
await expect(menu).toBeHidden();
await expect(field).toHaveValue(latest);
await expect(field).toBeFocused();
});
-60
View File
@@ -1,66 +1,6 @@
import type { Locator } from "@playwright/test";
import { expect, stubDesktop, test } from "./fixtures";
test("Find Usages places read and write filters with the other actions", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async () => {
const modulePath = "/src/features/code-insight/usages.ts";
const { useUsagesPopup } = await import(modulePath);
const path = "/dev/acme-api/src/SettlementService.ts";
const lines = ["const current = settlement;", "settlement = next;"];
window.__ipc.handlers.fs_read_text = () => lines.join("\n");
useUsagesPopup.setState({
open: true,
anchor: { x: 100, y: 150 },
symbol: "settlement",
loading: false,
scope: "project",
groups: [
{
path,
usages: lines.map((text, line) => ({
path,
line,
col: text.indexOf("settlement"),
endCol: text.indexOf("settlement") + "settlement".length,
text,
access: line === 0 ? "read" : "write",
})),
},
],
});
});
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
const read = { name: "Show read accesses", exact: true };
const write = { name: "Show write accesses", exact: true };
const actions = popup.getByRole("button", { name: "Show Preview", exact: true }).locator("..");
await expect(popup.getByRole("option")).toHaveCount(2);
for (const width of [1120, 540]) {
await page.setViewportSize({ width, height: 640 });
expect(await actions.getByRole("toolbar", { name: "Usage access filters", exact: true }).count()).toBe(1);
await expect(actions.getByRole("button", read)).toBeInViewport({ ratio: 1 });
await expect(actions.getByRole("button", write)).toBeInViewport({ ratio: 1 });
}
await actions.getByRole("button", write).click();
await expect(popup.getByRole("option")).toHaveCount(1);
await popup.getByRole("button", { name: /Open in Find Window/ }).click();
const view = page.getByRole("region", { name: "Find Usages", exact: true });
const toolbar = view.getByRole("toolbar", { name: "Usages actions", exact: true });
const readButton = toolbar.getByRole("button", read);
const writeButton = toolbar.getByRole("button", write);
await expect(readButton).toHaveAttribute("aria-pressed", "true");
await expect(writeButton).toHaveAttribute("aria-pressed", "false");
const a = (await readButton.boundingBox())!;
const b = (await writeButton.boundingBox())!;
expect(a.x).toBeCloseTo(b.x, 0);
expect(b.y).toBeGreaterThanOrEqual(a.y + a.height);
await expect(view.locator("mark")).toHaveCount(1);
await writeButton.click();
await expect(view.locator("mark")).toHaveCount(2);
});
async function checkSize(icon: Locator, size = 16) {
const dimensions = await icon.evaluate((node) => {
const style = getComputedStyle(node);
+3 -36
View File
@@ -3,12 +3,11 @@ import { expect, openFromTree, stubDesktop, test } from "./fixtures";
test("Git annotations align dates and full author names at UI text size", async ({ workbench: page }) => {
const editor = await openFromTree(page, "build.gradle.kts");
await stubDesktop(page);
const longEmail = `reconciliation+${"regional-settlement-".repeat(5)}[email protected]`;
await page.evaluate(async (email) => {
await page.evaluate(async () => {
const root = "/dev/acme-api";
const file = `${root}/build.gradle.kts`;
const handlers = window.__ipc.handlers;
const lines = [
handlers.vcs_blame = () => [
{
commit: "a1234567".padEnd(40, "a"),
author: "Lena Park",
@@ -22,23 +21,6 @@ test("Git annotations align dates and full author names at UI text size", async
summary: "Review totals",
},
];
handlers.vcs_blame = () => lines;
handlers.vcs_log = ({ query }) => {
const { branch } = query as { branch?: string };
const line = lines.find(({ commit }) => commit === branch);
if (!line) return [];
return [
{
...line,
id: line.commit,
shortId: line.commit.slice(0, 8),
refs: [],
parents: [],
email: line === lines[0] ? "[email protected]" : email,
message: line.summary,
},
];
};
const projectModule = "/src/platform/project.ts";
const { useProject } = await import(/* @vite-ignore */ projectModule);
const { settings } = useProject.getState();
@@ -57,7 +39,7 @@ test("Git annotations align dates and full author names at UI text size", async
const actionsModule = "/src/platform/actions.ts";
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
await executeAction("vcs.annotate", file);
}, longEmail);
});
const gutter = editor.locator(".cm-vcs-blame");
const first = gutter.locator("[data-commit]").filter({ hasText: "3 May 2026" });
@@ -69,21 +51,6 @@ test("Git annotations align dates and full author names at UI text size", async
await expect
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
.toBeLessThan(1);
await first.hover();
const details = page.getByRole("dialog").filter({ has: page.getByTitle("Show Commit in Git Log") });
await expect(details).toContainText("[email protected]");
await expect.poll(async () => (await details.boundingBox())!.width).toBeLessThan(400);
await expect(details.getByTitle("Show Commit in Git Log")).toHaveCSS(
"font-family",
await details.evaluate((el) => getComputedStyle(el).fontFamily),
);
await page.setViewportSize({ width: 430, height: 640 });
await second.hover();
await expect(details).toContainText(longEmail);
await expect(details).toBeInViewport({ ratio: 1 });
await expect.poll(() => details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
const uiSize = await editor.evaluate((el) => getComputedStyle(el).getPropertyValue("--fs-ui").trim());
await expect(firstAuthor).toHaveCSS("font-size", uiSize);
-104
View File
@@ -1,104 +0,0 @@
import { expect, stubDesktop, test } from "./fixtures";
const rootSubject = "Start warehouse reporting";
const mergeSubject = "Merge reporting changes";
const firstSubject = "Align regional settlement totals with the warehouse ledger before monthly reconciliation closes";
const secondSubject = "Keep archived settlement adjustments in the regional audit trail after the ledger is rebuilt";
test("Git Log commit choices fit their rows and navigate by keyboard after filtering", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1040, height: 700 });
await stubDesktop(page);
await page.evaluate(
async ({ mergeSubject, firstSubject, secondSubject, rootSubject }) => {
const root = "/dev/acme-api";
const changes = [
[mergeSubject, "Merge Author", [1, 2]],
[firstSubject, "Priya Kapoor", [3]],
[secondSubject, "Morgan Olsen", [3]],
[rootSubject, "Initial Author", []],
] as const;
const id = (i: number) => String(i + 1).repeat(40);
const commits = changes.map(([summary, author, parents], i) => ({
id: id(i),
shortId: id(i).slice(0, 8),
parents: parents.map(id),
refs: i === 0 ? ["HEAD", "main"] : [],
author,
email: "[email protected]",
timeMs: Date.UTC(2026, 10, 15 - i, 10 + i, 30),
summary,
message: summary,
}));
const handlers = window.__ipc.handlers;
handlers.vcs_log = ({ query }) => {
const { skip, limit, range } = query as { skip: number; limit: number; range?: string };
return range ? [] : commits.slice(skip, limit ? skip + limit : undefined);
};
handlers.vcs_log_refs = () => ({});
handlers.vcs_log_users = () => [];
handlers.vcs_branches = () => [];
handlers.vcs_branch_info = () => ({ head: "main", headCommit: id(0), ahead: 0, behind: 0 });
handlers.vcs_config_get = () => null;
handlers.vcs_commit_files = () => [];
handlers.vcs_log_details_batch = ({ revisions }) =>
(revisions as string[]).map(() => ({ message: "", containingBranches: [], signature: "N" }));
const vcsModule = "/src/features/vcs/store.ts";
const contextModule = "/src/platform/context.ts";
const actionsModule = "/src/platform/actions.ts";
const { useVcs } = await import(/* @vite-ignore */ vcsModule);
const { setContext } = await import(/* @vite-ignore */ contextModule);
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: true });
setContext("vcsAvailable", true);
await executeAction("vcs.showLog");
},
{ mergeSubject, firstSubject, secondSubject, rootSubject },
);
const log = page.getByRole("listbox", { name: "Commits", exact: true });
const merge = log.getByRole("option", { name: new RegExp(mergeSubject) });
await merge.click();
await log.press("ArrowRight");
const chooser = page.getByRole("dialog", { name: "Select Parent Commit", exact: true });
const options = chooser.getByRole("option");
const filter = chooser.getByRole("combobox", { name: "Search commits" });
await expect(filter).toBeFocused();
await expect(options).toHaveCount(2);
const before = (await chooser.boundingBox())!;
expect(before.height).toBeLessThan(200);
const first = options.filter({ hasText: firstSubject });
const subject = first.getByText(firstSubject, { exact: true });
const author = first.getByText("Priya Kapoor", { exact: true });
const hash = first.getByText("22222222", { exact: true });
await expect(subject).toHaveCSS("font-size", "13px");
await expect(author).toHaveCSS("font-size", "12px");
expect((await subject.boundingBox())!.y).toBeLessThan((await hash.boundingBox())!.y);
await expect(subject.locator("..")).toHaveAttribute("title", /Priya Kapoor/);
await page.setViewportSize({ width: 440, height: 520 });
const narrow = (await chooser.boundingBox())!;
expect(narrow.x + narrow.width).toBeLessThanOrEqual(440);
expect(await chooser.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1);
await filter.fill("No such change");
await expect(chooser.getByText("No commits", { exact: true })).toBeVisible();
await filter.press("Enter");
await expect(chooser).toBeVisible();
await filter.fill("Morgan Olsen");
await expect(options).toHaveCount(1);
await expect(options.first()).toContainText(secondSubject);
await filter.fill("");
await expect(options).toHaveCount(2);
await filter.press("ArrowDown");
await expect(options.filter({ hasText: secondSubject })).toHaveAttribute("aria-selected", "true");
await filter.press("Enter");
await expect(chooser).toBeHidden();
await expect(log.getByRole("option", { name: new RegExp(secondSubject) })).toHaveAttribute("aria-selected", "true");
await log.getByRole("option", { name: new RegExp(rootSubject) }).click();
await log.press("ArrowLeft");
const children = page.getByRole("dialog", { name: "Select Child Commit", exact: true });
await expect(children.getByRole("option")).toHaveCount(2);
await children.getByRole("option", { name: new RegExp(firstSubject) }).click();
await expect(children).toBeHidden();
await expect(log.getByRole("option", { name: new RegExp(firstSubject) })).toHaveAttribute("aria-selected", "true");
});
-24
View File
@@ -12,30 +12,6 @@ const names = [
"InvoicePublisher.ts",
];
test("a pinned editor tab can be unpinned from the hidden tabs list", async ({ workbench: page }) => {
await page.setViewportSize({ width: 700, height: 650 });
await page.evaluate(async (first) => {
const module = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ module);
await editorService().openFile(`/dev/acme-api/${first}`);
}, names[0]!);
const strip = page.getByRole("tablist", { name: "Editor tabs" });
const tab = strip.getByRole("tab", { name: names[0], exact: true });
await tab.click({ button: "right" });
await page.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
await page.evaluate(async (files) => {
const module = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ module);
for (const name of files) await editorService().openFile(`/dev/acme-api/${name}`);
}, names.slice(1));
await strip.evaluate((element) => (element.scrollLeft = element.scrollWidth));
await page.getByRole("button", { name: "Show Hidden Tabs" }).click();
const row = page.getByRole("grid", { name: "Hidden Editor Tabs" }).getByRole("row").filter({ hasText: names[0]! });
await expect(row.getByRole("button", { name: "Close Tab", exact: true })).toHaveCount(0);
await row.getByRole("button", { name: "Unpin Tab", exact: true }).click();
await expect(tab).toHaveCount(1);
});
test("the editor overflow lists clipped tabs and can close or open one without touching visible tabs", async ({
workbench: page,
}) => {
-48
View File
@@ -1,48 +0,0 @@
import { expect, stubDesktop, test } from "./fixtures";
test("image controls and metadata stay readable in a narrow editor", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1080, height: 700 });
await stubDesktop(page);
await page.evaluate(async () => {
const path = "/dev/acme-api/status.svg";
const image =
'<svg xmlns="http://www.w3.org/2000/svg" width="128" height="96"><rect width="128" height="96"/></svg>';
window.__ipc.handlers.fs_read_image = () => "data:image/svg+xml," + encodeURIComponent(image);
window.__ipc.handlers.fs_probe = () => ({ size: 4096, binary: false, tooLarge: false });
const contributions = "/src/workbench/contributions.ts";
const { editorService } = await import(/* @vite-ignore */ contributions);
await editorService().openFile(path);
});
const toolbars = page.getByRole("toolbar", { name: "Image viewer", exact: true });
const toolbar = toolbars.last();
const zoomIn = toolbar.getByRole("button", { name: "Zoom In", exact: true });
const actualSize = toolbar.getByRole("button", { name: "Actual Size", exact: true });
const chessboard = toolbar.getByRole("button", { name: "Show Chessboard", exact: true });
const showText = toolbar.getByRole("button", { name: "Open as Text", exact: true });
const dimensions = toolbar.getByText(/128\s*×\s*96/);
await expect(page.getByRole("img", { name: "status.svg", exact: true })).toBeVisible();
await expect(dimensions).toBeVisible();
const wideHeight = (await toolbar.boundingBox())!.height;
await page.getByRole("button", { name: "Split Right", exact: true }).click();
await expect(toolbars).toHaveCount(2);
await page.setViewportSize({ width: 640, height: 570 });
expect(await dimensions.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
expect((await toolbar.boundingBox())!.height).toBeGreaterThan(wideHeight);
expect((await dimensions.boundingBox())!.y).toBeGreaterThan((await zoomIn.boundingBox())!.y);
await expect(dimensions).toHaveCSS("font-size", "13px");
await expect(showText).toHaveCSS("white-space", "nowrap");
for (const item of [zoomIn, actualSize, chessboard, showText, dimensions]) {
await expect(item).toBeInViewport({ ratio: 1 });
}
await expect(toolbar.getByText("4.0 KB", { exact: true })).toBeVisible();
await zoomIn.click();
await expect(toolbar.getByText("125%", { exact: true })).toBeVisible();
await actualSize.click();
await expect(toolbar.getByText("100%", { exact: true })).toBeVisible();
await chessboard.click();
await expect(chessboard).toHaveAttribute("aria-pressed", "false");
await showText.click();
await expect(page.locator(".cm-content")).toBeVisible();
});
-4
View File
@@ -83,10 +83,6 @@ test("links independent Gradle roots, runs identical task paths in their own bui
});
const tasks = tree.getByRole("treeitem", { name: /^assemble\b/ });
await expect(tasks).toHaveCount(2);
expect(await tasks.allTextContents()).toEqual(["assemble", "assemble"]);
for (const task of await tasks.all()) {
await expect(task).toHaveAccessibleDescription("Assembles this project");
}
await page.screenshot({ path: info.outputPath("gradle-two-roots.png"), animations: "disabled" });
await tasks.nth(0).dblclick();
-74
View File
@@ -1,74 +0,0 @@
import type { MavenModel } from "../src/platform/ipc";
import { expect, stubDesktop, test } from "./fixtures";
const maven: MavenModel = {
projects: [
{
pom: "pom.xml",
dir: "",
groupId: "dev.acme",
artifactId: "billing",
version: "1.0.0",
packaging: "jar",
displayName: "Billing",
parent: null,
modules: [],
aggregated: false,
plugins: [
{
groupId: "org.apache.maven.plugins",
artifactId: "maven-surefire-plugin",
version: "3.2.5",
prefix: "surefire",
goals: ["test"],
},
],
dependencies: [],
profiles: [],
javaVersion: 21,
command: "mvn",
options: [],
env: {},
},
],
profiles: [],
syncedAt: 1,
stale: false,
syncError: null,
};
test("Maven plugin rows give the name priority over coordinates in narrow docks", async ({ workbench: page }) => {
await stubDesktop(page);
await page.evaluate(async (maven) => {
window.__ipc.handlers.build_model = () => ({ maven, gradle: [] });
const buildModule = "/src/features/build-tools/store.ts";
const { loadModel, setExpanded } = await import(/* @vite-ignore */ buildModule);
await loadModel();
setExpanded("maven", new Set(["mvn:pom.xml", "mvn:pom.xml:plugins"]));
const dockModule = "/src/workbench/toolwindows/store.ts";
const { showToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ dockModule);
showToolWindow("maven", true);
setToolWindowSize("right", 190);
}, maven);
const tree = page.getByRole("tree", { name: "Maven projects" });
const coordinates = "(org.apache.maven.plugins:maven-surefire-plugin:3.2.5)";
const plugin = tree.getByRole("treeitem", { name: `surefire ${coordinates}`, exact: true });
const name = plugin.getByText("surefire", { exact: true });
const metadata = plugin.getByText(coordinates, { exact: true });
await expect(name).toBeVisible();
await expect(metadata).toHaveAttribute("title", coordinates);
const fit = (el: Element) => {
const range = document.createRange();
range.selectNodeContents(el);
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
};
expect(await name.evaluate(fit)).toBe(true);
expect(await metadata.evaluate(fit)).toBe(false);
expect(await metadata.evaluate((el) => getComputedStyle(el).color)).not.toBe(
await name.evaluate((el) => getComputedStyle(el).color),
);
await plugin.locator("[data-tree-toggle]").click();
await expect(tree.getByRole("treeitem", { name: "surefire:test", exact: true })).toBeVisible();
});
+2 -35
View File
@@ -11,7 +11,7 @@ async function openNewBranchDialog(
page: Page,
from?: string,
mergeBase = "1111111",
blocked: boolean | string = false,
blocked = false,
withPrefix = false,
) {
await stubDesktop(page);
@@ -43,10 +43,7 @@ async function openNewBranchDialog(
];
h.vcs_create_branch = ({ options }) =>
blocked && (options as { mode?: string } | null)?.mode === "normal"
? {
checkout: { kind: "localChanges", files: [typeof blocked === "string" ? blocked : "dirty.txt"] },
created: null,
}
? { checkout: { kind: "localChanges", files: ["dirty.txt"] }, created: null }
: { checkout: { kind: "done" }, created: { tip: "2222222", previousTip: null } };
h.vcs_merge_base = () => mergeBase;
const vcsModule = "/src/features/vcs/store.ts";
@@ -154,36 +151,6 @@ for (const [button, mode] of [
});
}
test("local changes review keeps file names and checkout choices visible", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1040, height: 740 });
const folder = "services/international-payments/regional-settlement/weekly-close/adjustments";
const path = `${folder}/ReceiptPolicy.ts`;
const { dialog, input } = await openNewBranchDialog(page, "2".repeat(40), "1111111", path);
await input.fill("topic");
await dialog.getByRole("button", { name: "Create", exact: true }).click();
const review = page.getByRole("dialog", { name: "Git Checkout Problem" });
const force = review.getByRole("button", { name: "Force Checkout", exact: true });
const smart = review.getByRole("button", { name: "Smart Checkout", exact: true });
const cancel = review.getByRole("button", { name: "Don't Checkout", exact: true });
await expect(force).toBeVisible();
expect((await force.boundingBox())!.x - (await review.boundingBox())!.x).toBeLessThan(24);
await page.setViewportSize({ width: 420, height: 480 });
const tree = review.getByRole("tree", { name: "Changed files" });
const row = tree.getByRole("treeitem", { name: `ReceiptPolicy.ts ${folder}`, exact: true });
await expect(row.getByTitle(path, { exact: true })).toBeVisible();
const file = row.getByText("ReceiptPolicy.ts", { exact: true });
await expect(file).toBeInViewport({ ratio: 1 });
expect(await file.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await expect(row.getByText(folder, { exact: true })).toHaveCSS("font-size", "12px");
const restoreHint = review.getByText(/Smart Checkout .* your changes and restores them/);
expect((await restoreHint.boundingBox())!.y).toBeLessThan((await tree.boundingBox())!.y);
for (const button of [force, smart, cancel]) await expect(button).toBeInViewport({ ratio: 1 });
await cancel.click();
await expect(review).toBeHidden();
expect(await ipcCalls(page, "vcs_create_branch")).toHaveLength(1);
});
test("pasted text has its spaces replaced", async ({ workbench: page }) => {
const { dialog, input } = await openNewBranchDialog(page);
await input.fill("");
-34
View File
@@ -1,34 +0,0 @@
import { expect, test } from "./fixtures";
test("fits notification body and actions below the dismiss button in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 420, height: 540 });
const title = "Validation failed for the catalog service";
const body = "The build stopped while checking the catalog response type.";
const action = "recheckCatalogServiceResponsePayloadAfterRegeneratingTypesForDevelopment";
await page.evaluate(
async ({ title, body, action }) => {
const servicePath = "/src/workbench/contributions.ts";
const { notifications } = await import(/* @vite-ignore */ servicePath);
notifications().notify({
level: "error",
title,
body,
actions: [{ label: action, run: () => document.body.setAttribute("data-validation-retried", "true") }],
});
},
{ title, body, action },
);
const balloon = page.getByRole("alert").filter({ hasText: title });
const message = balloon.getByText(body, { exact: true });
const dismiss = balloon.getByRole("button", { name: "Dismiss", exact: true });
const retry = balloon.getByRole("button", { name: action, exact: true });
await expect(balloon).toBeInViewport({ ratio: 1 });
const [messageBox, dismissBox] = await Promise.all([message.boundingBox(), dismiss.boundingBox()]);
expect(messageBox!.y).toBeGreaterThanOrEqual(dismissBox!.y + dismissBox!.height);
expect(messageBox!.x + messageBox!.width).toBeGreaterThanOrEqual(dismissBox!.x + dismissBox!.width - 1);
expect(await retry.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
await retry.click();
await expect(page.locator("body")).toHaveAttribute("data-validation-retried", "true");
await expect(balloon).toBeHidden();
});
+5 -56
View File
@@ -1,7 +1,9 @@
import type { EditorView } from "@codemirror/view";
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
test("Quick Evaluate and hover keep value previews usable in a narrow editor", async ({ workbench: page }) => {
test("Quick Evaluate opens an object tree that fits the editor and returns focus on Escape", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 445, height: 500 });
await stubDesktop(page);
await page.evaluate(async () => {
@@ -17,9 +19,7 @@ test("Quick Evaluate and hover keep value previews usable in a narrow editor", a
h.fs_probe = () => ({ size: 48, binary: false, tooLarge: false });
h.fs_read_text = () => "summary = {}\nsubtotal = 42\n";
h.debug_evaluate_in = ({ expression }) =>
expression === "summary"
? value("summary", `{'audit': '${"Regional settlement totals ".repeat(8)}'}`, "dict", 101)
: value("subtotal", "42", "int");
expression === "summary" ? value("summary", "{...}", "dict", 101) : value("subtotal", "42", "int");
h.debug_variables = ({ reference }) =>
reference === 101
? [value("audit", "{...}", "dict", 102), value("total", "47.74", "float")]
@@ -81,59 +81,8 @@ test("Quick Evaluate and hover keep value previews usable in a narrow editor", a
await evaluate(2);
await expect(hint.getByRole("tree")).toHaveCount(0);
await expect(hint).toHaveText(/subtotal\s*=\s*42/);
const scalar = hint.locator("[class*='_valueTooltip_']");
const uiFont = await page.locator("body").evaluate((el) => getComputedStyle(el).fontFamily);
await expect(scalar).toHaveCSS("font-family", uiFont);
await expect(scalar).toHaveCSS("font-size", "13px");
await expect(scalar).toHaveCSS("font-weight", "700");
await expect(scalar.locator(".cm-openidea-icon")).toHaveCount(1);
await content.press("Escape");
await expect(hint).toBeHidden();
await page.setViewportSize({ width: 620, height: 480 });
await page.evaluate(async () => {
const layoutModule = "/src/workbench/toolwindows/store.ts";
const servicesModule = "/src/workbench/contributions.ts";
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
moveToolWindow("project", "left");
setToolWindowSize("left", 220);
toolWindowService().show("project", false);
});
await expect.poll(async () => (await editor.boundingBox())!.x).toBeGreaterThan(160);
const position = await content.evaluate((el) => {
const { view } = (el as HTMLElement & { cmTile: { view: EditorView } }).cmTile;
return view.coordsAtPos(view.state.doc.line(1).from + 2);
});
await page.mouse.move(position!.left, (position!.top + position!.bottom) / 2);
const hover = page.locator(".cm-tooltip-hover").locator("[class*='_valueTooltip_']");
const expand = hover.getByRole("button", { name: "Expand value" });
await expect(hover).toContainText("Regional settlement totals");
await expect(hover).toHaveCSS("font-family", uiFont);
const summary = hover.locator("[class*='_valueText_']");
const textBox = (await summary.boundingBox())!;
const controlBox = (await expand.boundingBox())!;
const iconBox = (await hover.locator(".cm-openidea-icon").boundingBox())!;
expect(textBox.height).toBeGreaterThan(20);
expect(Math.abs(controlBox.y - iconBox.y)).toBeLessThan(1);
expect(textBox.x).toBeGreaterThanOrEqual(iconBox.x + iconBox.width);
const fitsEditor = async () => {
const tooltip = await hover.boundingBox();
const pane = (await editor.boundingBox())!;
return !!tooltip && tooltip.x >= pane.x - 1 && tooltip.x + tooltip.width <= pane.x + pane.width + 1;
};
await expect.poll(fitsEditor).toBe(true);
await page.setViewportSize({ width: 555, height: 480 });
await expect.poll(fitsEditor).toBe(true);
await expand.click();
const pinned = hint.getByRole("tree", { name: "summary" });
await expect(pinned).toBeFocused();
await pinned.press("Escape");
await expect(content).toBeFocused();
const calls = await ipcCalls(page, "debug_evaluate_in");
expect(calls.filter((call) => call.context === "watch")).toEqual([
expect(await ipcCalls(page, "debug_evaluate_in")).toEqual([
{ session: 91, frameId: 11, expression: "summary", context: "watch" },
{ session: 91, frameId: 11, expression: "subtotal", context: "watch" },
]);
expect(calls).toContainEqual({ session: 91, frameId: 11, expression: "summary", context: "hover" });
});
-75
View File
@@ -1,75 +0,0 @@
import type { SearchQuery } from "../src/bindings";
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
test("Replace All keeps both values readable and the actions visible", async ({ workbench: page }) => {
const pattern = `LEGACY_${"MONTH_END_RECONCILIATION_INPUT_".repeat(15)}END`;
const replacement = `ACTIVE_${"MONTH_END_RECONCILIATION_OUTPUT_".repeat(18)}END`;
await page.emulateMedia({ reducedMotion: "reduce" });
await page.setViewportSize({ width: 1040, height: 700 });
await stubDesktop(page);
await page.evaluate((pattern) => {
window.__ipc.handlers.search_validate = () => null;
window.__ipc.handlers.search_start = ({ query, onEvent }) => {
if ((query as SearchQuery).pattern !== pattern) return null;
setTimeout(() => {
for (const relPath of ["invoice.txt", "receipt.txt"]) {
window.__ipc.send(onEvent, {
type: "file",
file: {
path: `/dev/acme-api/${relPath}`,
relPath,
matches: [{ line: 0, text: pattern, ranges: [[0, pattern.length]], textOffset: 0 }],
},
});
}
window.__ipc.send(onEvent, {
type: "done",
summary: { files: 2, matches: 2, limitHit: false, cancelled: false, elapsedMs: 1 },
});
}, 20);
return null;
};
}, pattern);
await page.keyboard.press("Meta+Shift+r");
const popup = page.getByRole("dialog", { name: "Replace in Files", exact: true });
await popup.getByRole("textbox", { name: "Text to find", exact: true }).fill(pattern);
const replacementInput = popup.getByRole("textbox", { name: "Replace with", exact: true });
await replacementInput.fill(replacement);
await expect(popup.getByRole("listbox", { name: "Matches" }).getByRole("option")).toHaveCount(2);
await page.setViewportSize({ width: 440, height: 520 });
await popup.getByRole("button", { name: "Replace All", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Replace All", exact: true });
const findText = dialog.getByRole("region", { name: "Text to find", exact: true });
const replaceText = dialog.getByRole("region", { name: "Replace with", exact: true });
const replace = dialog.getByRole("button", { name: "Replace", exact: true });
const cancel = dialog.getByRole("button", { name: "Cancel", exact: true });
await expect(findText).toHaveText(pattern);
await expect(replaceText).toHaveText(replacement);
await expect(dialog.getByText("Replace 2 occurrences in 2 files?", { exact: true })).toBeVisible();
const bottom = (await replace.boundingBox())!.y;
for (const item of [findText, replaceText]) {
await expect(item).toHaveCSS("font-size", "13px");
expect(await item.evaluate((el) => el.scrollHeight > el.clientHeight && el.scrollWidth === el.clientWidth)).toBe(
true,
);
await item.focus();
await page.keyboard.press("End");
await expect.poll(() => item.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
}
expect((await replace.boundingBox())!.y).toBeCloseTo(bottom, 0);
await expect(replace).toBeInViewport({ ratio: 1 });
await expect(cancel).toBeInViewport({ ratio: 1 });
await cancel.click();
await expect(dialog).toBeHidden();
await page.setViewportSize({ width: 1040, height: 700 });
await replacementInput.fill("");
await popup.getByRole("button", { name: "Open in Find Window", exact: true }).click();
const findWindow = page.getByRole("region", { name: "Find", exact: true });
await findWindow.getByRole("button", { name: "Replace All", exact: true }).click();
await expect(findText).toHaveText(pattern);
await expect(replaceText).toHaveText("Empty text");
await cancel.click();
expect(await ipcCalls(page, "replace_in_files")).toHaveLength(0);
});
-51
View File
@@ -581,54 +581,3 @@ test("CMake builds the selected target in Build before starting only the applica
await expect(run.getByRole("tab", { name: "hello [Release, release]" })).toBeVisible();
await expect(run.getByText("COMPILER_OUTPUT", { exact: true })).toHaveCount(0);
});
test("test report export separates the format and destination in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 410, height: 500 });
await stubRun(
page,
[
{
kind: "stdout",
text: '{"Package":"example.com/checkout","Action":"pass","Test":"TestReceipt","Elapsed":0.1}\n',
},
],
0,
{ id: "go:report-tests", name: "Checkout tests", kind: "go", command: "go", args: ["test", "-json"], isTest: true },
);
await page.evaluate(() => {
window.__ipc.handlers.fs_entry_kind = () => {
throw { kind: "NotFound", message: "Not found" };
};
window.__ipc.handlers.fs_create_file_bytes = () => null;
});
await page.keyboard.press("Control+r");
const results = page.getByRole("toolbar", { name: "Test results" });
await results.getByRole("button", { name: "More Actions" }).click();
const exportItem = page.getByRole("menuitem", { name: "Export Test Results…" });
await expect(exportItem).toBeEnabled();
await exportItem.click();
const dialog = page.getByRole("dialog", { name: "Export Test Results" });
const html = dialog.getByRole("radio", { name: "HTML", exact: true });
const xml = dialog.getByRole("radio", { name: "XML", exact: true });
await expect(html).toBeVisible();
expect((await xml.boundingBox())!.y).toBeGreaterThan((await html.boundingBox())!.y);
const file = dialog.getByLabel("File name", { exact: true });
const folder = dialog.getByLabel("Folder", { exact: true });
const browse = dialog.getByRole("button", { name: "Browse…" });
await expect(file).toBeFocused();
await expect(file).toHaveValue("Test Results - Checkout tests.html");
await expect(folder).toHaveValue("/dev/acme-api");
await expect(browse).toBeInViewport({ ratio: 1 });
expect((await folder.boundingBox())!.width).toBeGreaterThan(180);
await file.fill("receipts.html");
await folder.fill("reports");
await xml.check();
await expect(file).toHaveValue("receipts.xml");
await expect(dialog.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled();
await dialog.getByRole("button", { name: "OK", exact: true }).click();
await expect(dialog).toBeHidden();
const [write] = await ipcCalls(page, "fs_create_file_bytes");
expect(write).toMatchObject({ path: "/dev/acme-api/reports/receipts.xml" });
});
+20 -152
View File
@@ -1,145 +1,39 @@
import type { Page } from "@playwright/test";
import type { BeforeLaunchTask } from "../src/bindings";
import { expect, test } from "./fixtures";
test("expands VM options beside the field and returns edited text to the configuration", async ({
workbench: page,
}) => {
const original = "-Xmx512m\n-Ddemo.endpoint=https://example.test/" + "long-segment/".repeat(12);
await page.evaluate(async (vmOptions) => {
async function openConfigurations(page: Page, target?: string) {
await page.evaluate(async (target) => {
const path = "/src/features/run/store.ts";
const { useRun } = await import(/* @vite-ignore */ path);
const base = {
kind: "shell",
command: "/Users/developer/projects/acme/services/payments/scripts/start-development-server",
args: ["--watch"],
cwd: "/Users/developer/projects/acme/services/payments",
env: { NODE_ENV: "development" },
detected: false,
isTest: false,
debugAdapter: null,
};
useRun.setState({
configs: [
{
id: "layout:jvm",
name: "Catalog service",
kind: "application",
command: "java",
args: ["example.Catalog"],
params: { mainClass: "example.Catalog", vmOptions },
env: {},
cwd: null,
detected: false,
isTest: false,
debugAdapter: "java-debug",
...base,
id: "layout:app",
name: "Payments development server",
target,
beforeLaunch: [{ kind: "run", target: "layout:prepare" }],
},
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
],
editTarget: "layout:jvm",
selectedId: "layout:app",
loaded: true,
editorOpen: true,
});
}, original);
const config = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
const field = config.getByRole("textbox", { name: "VM options", exact: true });
const expanded = page.getByRole("dialog", { name: "VM options", exact: true });
const editor = expanded.getByRole("textbox", { name: "VM options", exact: true });
for (const width of [1100, 560]) {
await page.setViewportSize({ width, height: 760 });
await field.scrollIntoViewIfNeeded();
await field.press("Shift+Enter");
await expect(editor).toBeFocused();
await expect
.poll(async () => {
const source = (await field.boundingBox())!;
const popup = (await expanded.boundingBox())!;
const gap = Math.min(Math.abs(popup.y - source.y - source.height), Math.abs(source.y - popup.y - popup.height));
return popup.x >= 0 && popup.x + popup.width <= width && gap <= 6;
})
.toBe(true);
await expect.poll(() => editor.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeGreaterThan(0);
await editor.fill("-Xmx1g");
await editor.press("Escape");
await expect(expanded).toBeHidden();
await expect(field).toBeFocused();
await expect(field).toHaveValue(original);
}
const expand = config.getByRole("button", { name: "Expand (⇧⏎)", exact: true });
await expand.click();
await expect(editor).toBeFocused();
await editor.fill(original + "\n-Ddemo.mode=local");
await editor.press("Control+Enter");
await expect(expanded).toBeHidden();
await expect(field).toHaveValue(original + "\n-Ddemo.mode=local");
});
async function openConfigurations(page: Page, target?: string, beforeLaunch?: BeforeLaunchTask[]) {
await page.evaluate(
async ({ target, beforeLaunch }) => {
const path = "/src/features/run/store.ts";
const { useRun } = await import(/* @vite-ignore */ path);
const base = {
kind: "shell",
command: "/Users/developer/projects/acme/services/payments/scripts/start-development-server",
args: ["--watch"],
cwd: "/Users/developer/projects/acme/services/payments",
env: { NODE_ENV: "development" },
detected: false,
isTest: false,
debugAdapter: null,
};
useRun.setState({
configs: [
{
...base,
id: "layout:app",
name: "Payments development server",
target,
beforeLaunch: beforeLaunch ?? [{ kind: "run", target: "layout:prepare" }],
},
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
],
selectedId: "layout:app",
loaded: true,
editorOpen: true,
});
},
{ target, beforeLaunch },
);
}, target);
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true })).toBeVisible();
}
test("before-launch tasks wrap as ordered tags and keep their edit controls", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1150, height: 820 });
await openConfigurations(page, undefined, [
{ kind: "build" },
{ kind: "buildArtifacts" },
{ kind: "command", target: "make generate" },
]);
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
const tasks = dialog.getByRole("list", { name: "Before launch tasks", exact: true });
const build = tasks.getByRole("button", { name: "1. Build Project", exact: true });
const artifacts = tasks.getByRole("button", { name: "2. Build Artifacts", exact: true });
await tasks.scrollIntoViewIfNeeded();
await expect(build).toBeVisible();
expect((await build.boundingBox())!.y).toBeCloseTo((await artifacts.boundingBox())!.y, 0);
await expect(build).toHaveCSS("font-size", "13px");
await page.setViewportSize({ width: 520, height: 820 });
await expect.poll(() => tasks.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
const command = tasks.getByRole("textbox", { name: "Before launch command 3" });
expect((await command.boundingBox())!.y).toBeGreaterThan((await build.boundingBox())!.y + 20);
await command.fill("make report");
await build.press("Enter");
const actions = page.getByRole("menu", { name: "Task Actions", exact: true });
const moveDown = actions.getByRole("menuitem", { name: "Move Down", exact: true });
await expect(moveDown).toBeVisible();
await moveDown.click();
await expect(tasks.getByRole("button", { name: "1. Build Artifacts", exact: true })).toBeVisible();
const moved = tasks.getByRole("listitem").filter({
has: page.getByRole("button", { name: "2. Build Project", exact: true }),
});
await moved.getByRole("button", { name: "Remove Task" }).click();
await expect(tasks.getByRole("textbox", { name: "Before launch command 2" })).toHaveValue("make report");
await tasks.getByRole("button", { name: "Add task", exact: true }).click();
await page.getByRole("menuitem", { name: "Build Project", exact: true }).click();
await expect(tasks.getByRole("button", { name: "3. Build Project", exact: true })).toBeVisible();
});
test("long run target names leave room for configuration names in the sidebar", async ({ workbench: page }) => {
const target = "payments-development-shared-staging-runner-west";
await openConfigurations(page, target);
@@ -161,32 +55,6 @@ test("long run target names leave room for configuration names in the sidebar",
await expect(dialog.getByRole("textbox", { name: "Name", exact: true })).toHaveValue("Payments development server");
});
test("the configuration type list scrolls below its search field in a short window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 780, height: 370 });
await openConfigurations(page);
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
await dialog.getByRole("button", { name: "Add New Configuration", exact: true }).click();
const chooser = page.getByRole("dialog", { name: "Add New Configuration", exact: true });
const search = chooser.getByRole("textbox", { name: "Search configuration types" });
const list = chooser.getByRole("listbox", { name: "Configuration types" });
await expect(search).toBeFocused();
expect(await chooser.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeLessThanOrEqual(1);
expect(await list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(0);
await search.press("End");
const active = list.getByRole("option", { selected: true });
await expect(active).toBeInViewport({ ratio: 0.98 });
expect(await list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
await expect(active.locator("svg")).toHaveAttribute("width", "16");
await expect(search).toBeInViewport({ ratio: 1 });
await search.fill("Tomcat");
await expect(list.getByRole("option", { name: "Tomcat Server", selected: true })).toBeVisible();
await search.press("Enter");
await expect(chooser).toBeHidden();
await expect(dialog.getByRole("tab", { name: "Server", exact: true })).toBeVisible();
});
test("run configuration sidebar resizes with mouse and keyboard and remembers the layout", async ({
workbench: page,
}) => {
-63
View File
@@ -1,63 +0,0 @@
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
const prefix = "reconcile-regional-inventory-and-rebuild-order-settlement-cache-for-warehouse-";
const east = prefix + "east-stage";
const west = prefix + "west-stage";
const content = JSON.stringify(
{ name: "warehouse-tools", scripts: { [east]: "node east.js", [west]: "node west.js", build: "node build.js" } },
null,
2,
);
test("the npm gutter keeps distinct ends of long names and runs the selected script", async ({ workbench: page }) => {
await page.setViewportSize({ width: 440, height: 520 });
await stubDesktop(page);
await page.evaluate(async (text) => {
const backendPath = "/src/editor/core/backend.ts";
const servicePath = "/src/workbench/contributions.ts";
const { docBackend } = await import(/* @vite-ignore */ backendPath);
const { editorService } = await import(/* @vite-ignore */ servicePath);
const path = "/dev/acme-api/package.json";
docBackend().files.set(path, text);
const handlers = window.__ipc.handlers;
handlers.fs_probe = () => ({ size: text.length, binary: false, tooLarge: false });
handlers.fs_read_text = ({ path }) => docBackend().files.get(String(path)) ?? "";
handlers.fs_read_dir = () => [];
handlers.run_configs = () => [];
handlers.run_start = ({ config }) => ({
id: 7,
configId: (config as { id: string }).id,
name: (config as { name: string }).name,
pid: 4242,
running: true,
pty: false,
});
await editorService().openFile(path);
}, content);
const editor = page.locator(".cm-editor");
const menu = page.getByRole("menu", { name: "Context menu" });
for (const name of [east, west]) {
await editor.getByTitle("Run '" + name + "'", { exact: true }).click();
const label = "Run 'npm run " + name + "'";
const run = menu.getByRole("menuitem", { name: label, exact: true });
const end = run.getByText(label.slice(-12), { exact: true });
await expect(end).toBeVisible();
await expect(end.locator("..")).toHaveAttribute("title", label);
expect(await end.evaluate((node) => node.clientWidth >= node.scrollWidth)).toBe(true);
const start = end.locator("..").locator(":scope > span").first();
expect(await start.evaluate((node) => node.clientWidth < node.scrollWidth)).toBe(true);
await expect(start).toHaveCSS("text-overflow", "ellipsis");
const titleUnderPointer = await start.evaluate((node) => {
const { x, y, width, height } = node.getBoundingClientRect();
return document.elementFromPoint(x + width / 2, y + height / 2)?.getAttribute("title");
});
expect(titleUnderPointer).toBe(label);
await expect(run).toBeFocused();
if (name === east) await run.press("Escape");
else await run.press("Enter");
await expect(menu).toBeHidden();
}
await expect
.poll(async () => ipcCalls(page, "run_start"))
.toMatchObject([{ config: { args: ["run", west], kind: "npm" } }]);
});
-60
View File
@@ -1,64 +1,4 @@
import { doubleShift, expect, stubDesktop, test } from "./fixtures";
test("Search Everywhere keeps line numbers visible beside long Text result filenames", async ({ workbench: page }) => {
const relPath = "config/InternationalSettlementReconciliationEndpointsForStagingEnvironments.ts";
const query = "settlementEndpoint";
const text = `const ${query} = "/staging/settlement";`;
await stubDesktop(page);
await page.evaluate(
({ relPath, text, query }) => {
window.__ipc.handlers.search_start = (args) => {
setTimeout(() => {
const matches = [12344, 12345].map((line) => ({
line,
text,
ranges: [[6, 6 + query.length]],
textOffset: 0,
}));
window.__ipc.send(args.onEvent, {
type: "file",
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
});
window.__ipc.send(args.onEvent, {
type: "done",
summary: { files: 1, matches: 2, limitHit: false, cancelled: false, elapsedMs: 4 },
});
}, 20);
return null;
};
},
{ relPath, text, query },
);
await doubleShift(page);
const dialog = page.getByRole("dialog", { name: "Search Everywhere" });
await dialog.getByRole("tab", { name: "Text", exact: true }).click();
const search = dialog.getByRole("combobox", { name: "Search query" });
await search.fill(query);
const rows = dialog.getByRole("option");
await expect(rows).toHaveCount(2);
for (const width of [920, 440]) {
await page.setViewportSize({ width, height: 640 });
for (const line of [12345, 12346]) {
const row = rows.filter({ hasText: String(line) });
await expect(row.locator("mark")).toHaveText(query);
expect(
await row.evaluate((el) => {
const location = el.lastElementChild!;
const lineText = location.lastChild!;
const range = document.createRange();
range.selectNodeContents(lineText);
const bounds = range.getBoundingClientRect();
const clip = location.getBoundingClientRect();
return bounds.width > 0 && bounds.left >= clip.left && bounds.right <= clip.right + 1;
}),
).toBe(true);
await expect(row.getByText(relPath.split("/").at(-1)!, { exact: true })).toHaveAttribute("title", relPath);
}
}
await search.press("ArrowDown");
await expect(rows.nth(1)).toHaveAttribute("aria-selected", "true");
});
import type { Page } from "@playwright/test";
test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => {
+2 -28
View File
@@ -15,7 +15,7 @@ async function run(page: Page, id: string) {
}, id);
}
async function stubFindMatches(page: Page, firstPath = LONG_RESULT_PATH) {
async function stubFindMatches(page: Page) {
await stubDesktop(page);
await page.evaluate((longPath) => {
window.__ipc.handlers.search_validate = () => null;
@@ -39,7 +39,7 @@ async function stubFindMatches(page: Page, firstPath = LONG_RESULT_PATH) {
}, 20);
return null;
};
}, firstPath);
}, LONG_RESULT_PATH);
}
async function expectControlsFit(page: Page) {
@@ -205,29 +205,3 @@ test("Find in Files prioritizes the preview and remembers an adjusted split", as
await expect(handle).toBeAttached();
await expect.poll(resultsShare).toBeCloseTo(adjusted, 2);
});
test("Find in Files keeps the file and its parent folder visible in the preview caption", async ({
workbench: page,
}) => {
await page.setViewportSize({ width: 400, height: 570 });
const prefix = "config/generated/regional-integrations/sandbox/development/notifications";
const name = "RegionalLedgerSettings.txt";
const path = `${prefix}/runtime/${name}`;
await stubFindMatches(page, path);
await run(page, "find.inPath");
const dialog = page.getByRole("dialog", { name: "Find in Files" });
const search = dialog.getByPlaceholder("Search");
await search.fill("http://localhost:8080");
const preview = dialog.locator("[data-panel][id=preview]");
const caption = preview.getByTitle(path, { exact: true });
const folder = caption.getByText("/runtime", { exact: true });
const beginning = caption.getByText(prefix, { exact: true });
await expect(caption.getByText(name, { exact: true })).toBeInViewport({ ratio: 1 });
await expect(folder).toBeInViewport({ ratio: 1 });
await expect(folder).toHaveCSS("font-size", "13px");
expect(await beginning.evaluate((el) => el.scrollWidth > el.clientWidth)).toBe(true);
expect(await folder.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
await search.press("ArrowDown");
await search.press("ArrowDown");
await expect(preview.getByTitle("config/endpoint-1.txt", { exact: true })).toContainText("endpoint-1.txt");
});
-59
View File
@@ -1,59 +0,0 @@
import { expect, test } from "./fixtures";
test("Find in Files keeps the scope list and pattern editor usable in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1040, height: 700 });
const longName = "Regional settlement reconciliation sources for month-end audit and publication";
await page.evaluate(async (longName) => {
const search = "/src/platform/search.ts";
const { saveCustomScopes } = await import(/* @vite-ignore */ search);
saveCustomScopes(
Array.from({ length: 26 }, (_, i) => ({
name: i ? `Reconciliation scope ${i + 1}` : longName,
pattern: i ? `file:src/scope-${i + 1}//*` : "file:src/reconciliation//*",
})),
);
}, longName);
await page.keyboard.press("Meta+Shift+F");
const find = page.getByRole("dialog", { name: "Find in Files", exact: true });
await find.getByRole("tab", { name: "Scope", exact: true }).click();
const openScopes = find.getByRole("button", { name: "Edit Scopes…", exact: true });
await openScopes.click();
const dialog = page.getByRole("dialog", { name: "Scopes", exact: true });
const list = dialog.getByRole("list", { name: "Scopes", exact: true });
const name = dialog.getByRole("textbox", { name: "Name:", exact: true });
const pattern = dialog.getByRole("textbox", { name: "Pattern:", exact: true });
await expect(pattern).toHaveValue("file:src/reconciliation//*");
expect(await list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(100);
await expect(list.getByRole("button", { name: longName })).toHaveAttribute("title", longName);
expect((await list.boundingBox())!.x).toBeLessThan((await name.boundingBox())!.x);
await page.setViewportSize({ width: 460, height: 530 });
const fields = (await pattern.boundingBox())!;
expect(fields.y).toBeGreaterThanOrEqual((await list.boundingBox())!.y + (await list.boundingBox())!.height);
expect(fields.width).toBeGreaterThan(250);
await list.evaluate((el) => (el.scrollTop = el.scrollHeight));
expect((await pattern.boundingBox())!.y).toBeCloseTo(fields.y, 0);
const toolbar = dialog.getByRole("toolbar", { name: "Scopes actions" });
const add = toolbar.getByRole("button", { name: "Add Scope", exact: true });
const ok = dialog.getByRole("button", { name: "OK", exact: true });
await expect(add).toBeInViewport({ ratio: 1 });
await expect(ok).toBeInViewport({ ratio: 1 });
await name.fill("Unsaved selection");
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
await openScopes.click();
await expect(name).toHaveValue(longName);
await add.click();
const draft = list.getByRole("button", { name: "Unnamed", exact: true });
await expect(draft).toHaveAttribute("aria-current", "true");
await expect(draft).toBeInViewport({ ratio: 1 });
await expect(ok).toBeDisabled();
await name.fill("Release inputs");
await pattern.fill("file:src/release//*");
await ok.click();
await expect(dialog).toBeHidden();
await openScopes.click();
await list.getByRole("button", { name: "Release inputs", exact: true }).click();
await expect(pattern).toHaveValue("file:src/release//*");
});
+1 -26
View File
@@ -75,7 +75,7 @@ for (const locale of ["en", "zh"]) {
const path = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ path)).setLocale(locale);
}, locale);
for (const id of ["appearance", "editor.font", "general", "general.httpProxy", "vcs.log"]) {
for (const id of ["appearance", "editor.font", "general", "general.httpProxy"]) {
await selectPage(page, id);
const body = page.locator("[class*='pageBody']");
for (const width of [1000, 784, 640, 520]) {
@@ -108,31 +108,6 @@ test("keeps Open project in options within narrow System Settings", async ({ wor
expect(overflow).toBeLessThanOrEqual(1);
});
test("Git Log settings group display and column options with aligned checkboxes", async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
await selectPage(page, "vcs.log");
const view = dialog.getByRole("region", { name: "View Options" });
const columns = dialog.getByRole("region", { name: "Visible columns" });
const tagNames = view.getByRole("checkbox", { name: "Show tag names" });
const hash = columns.getByRole("checkbox", { name: "Hash" });
await expect(view.getByRole("checkbox")).toHaveCount(5);
await expect(columns.getByRole("checkbox")).toHaveCount(4);
for (const width of [1000, 520]) {
await page.setViewportSize({ width, height: 760 });
// Read both rows together once the dialog has finished opening and relaid out.
await expect
.poll(async () => Math.abs((await tagNames.boundingBox())!.x - (await hash.boundingBox())!.x))
.toBeLessThan(0.5);
}
await expect(hash).not.toBeChecked();
await hash.focus();
await page.keyboard.press("Space");
await expect(hash).toBeChecked();
});
test("settings sidebar resizes with mouse and keyboard and remembers its width", async ({ workbench: page }) => {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
-38
View File
@@ -1,38 +0,0 @@
import { expect, test } from "./fixtures";
test("Settings aligns search results with their parent pages and honors smaller tree indents", async ({
workbench: page,
}) => {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
const search = dialog.getByRole("textbox", { name: "Search settings" });
const tree = dialog.getByRole("tree", { name: "Settings pages" });
await search.fill("Language Defaults");
const editor = tree.getByRole("treeitem", { name: "Editor", exact: true });
const scheme = tree.getByRole("treeitem", { name: "Color Scheme", exact: true });
const defaults = tree.getByRole("treeitem", { name: "Language Defaults", exact: true });
await expect(defaults).toHaveAttribute("aria-selected", "true");
await expect(defaults.locator("mark")).toHaveText(["Language", "Defaults"]);
const insets = () =>
Promise.all(
[editor, scheme, defaults].map((row) =>
row.locator(":scope > span:last-child").evaluate((label) => {
const left = label.closest('[role="tree"]')!.getBoundingClientRect().left;
return Math.round(label.getBoundingClientRect().left - left);
}),
),
);
await expect.poll(insets).toEqual([28, 44, 60]);
await page.setViewportSize({ width: 580, height: 720 });
await expect.poll(insets).toEqual([28, 44, 60]);
await page.evaluate(() => document.documentElement.style.setProperty("--tree-indent", "12px"));
await expect.poll(insets).toEqual([28, 40, 52]);
await search.press("ArrowUp");
await expect(scheme).toHaveAttribute("aria-selected", "true");
await search.press("ArrowUp");
await expect(editor).toHaveAttribute("aria-selected", "true");
await expect(search).toBeFocused();
});
-44
View File
@@ -1,44 +0,0 @@
import { expect, test } from "./fixtures";
test("shortcut assignment fits the first stroke and conflict names in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 336, height: 540 });
await page.keyboard.press("Meta+,");
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
await settings.getByRole("treeitem", { name: "Keymap", exact: true }).click();
await settings.getByRole("textbox", { name: "Search actions" }).fill("Find Action");
const action = settings.getByRole("treeitem", { name: /Find Action/ });
await action.click();
await settings.getByRole("button", { name: "Add Keyboard Shortcut", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Keyboard Shortcut: Find Action…", exact: true });
const first = dialog.getByRole("textbox", { name: "First stroke" });
const body = dialog.locator("[data-dialog-body]");
const titleBar = dialog.locator("[data-dialog-titlebar]");
await expect(first).toBeFocused();
await expect(titleBar).toHaveText("Keyboard Shortcut");
await expect(body.getByText("Find Action…", { exact: true })).toBeVisible();
const firstBounds = (await first.boundingBox())!;
const bodyBounds = (await body.boundingBox())!;
expect(firstBounds.width).toBeGreaterThan(bodyBounds.width - 32);
const conflicts = dialog.getByRole("list", { name: "Conflicts:" });
await expect(conflicts).toHaveCount(0);
await first.press("Meta+Alt+L");
await expect(conflicts).toBeVisible();
await expect(conflicts.getByRole("listitem").filter({ hasText: "Reformat Code" }).first()).toBeVisible();
expect(await conflicts.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
expect(
await conflicts
.getByRole("listitem")
.evaluateAll((rows) => rows.every((row) => row.scrollHeight <= row.clientHeight)),
).toBe(true);
expect(await body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
const ok = dialog.getByRole("button", { name: "OK", exact: true });
await ok.click();
const confirmation = page.getByRole("dialog", { name: "Warning", exact: true });
await expect(confirmation.getByRole("list").getByText("Reformat Code", { exact: true })).toHaveCount(2);
await confirmation.getByRole("button", { name: "Leave", exact: true }).click();
await expect(dialog).toBeHidden();
await expect(action.locator("kbd").filter({ hasText: "⌥⌘L" })).toHaveCount(1);
});
-3
View File
@@ -102,9 +102,6 @@ test("edits the staged version and keeps an unsaved draft when the index changes
await expect(headPane).toContainText("val committed = 0");
await expect(indexPane).toContainText("val external = 3");
await expect(localPane).not.toBeEmpty();
const indexHeading = page.getByTitle(`Staged (index) ${path}`, { exact: true });
await expect(indexHeading.getByText("build.gradle.kts", { exact: true })).toBeVisible();
await expect(indexHeading.getByText("Staged (index)", { exact: true })).toBeVisible();
const working = await localPane.textContent();
await page.getByRole("button", { name: "Unstage Change", exact: true }).click();
-36
View File
@@ -1,41 +1,5 @@
import { expect, openFromTree, test } from "./fixtures";
test("the line separator menu has a heading and keeps the current choice visible", async ({ workbench: page }) => {
await openFromTree(page, "build.gradle.kts");
const status = page.locator('[data-status-item="editor.lineEnding"]').getByRole("button");
const menu = page.getByRole("menu", { name: /^Line Separator$/i });
const windows = "Windows (\\r\\n)";
const unix = "Unix and macOS (\\n)";
const classic = "Classic Mac OS (\\r)";
await expect(status).toHaveText("LF");
await status.click();
const heading = menu.locator("..").getByText("Line Separator", { exact: true });
expect(await heading.count()).toBe(1);
await expect(heading).toHaveCSS("font-size", "13px");
await expect(menu.locator('[role^="menuitem"]')).toHaveText([windows, unix, classic]);
await page.setViewportSize({ width: 540, height: 540 });
await expect(heading).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitemcheckbox", { name: unix, checked: true })).toBeInViewport({ ratio: 1 });
await expect(menu.getByRole("menuitem", { name: windows })).toBeFocused();
await page.keyboard.press("Enter");
await expect(status).toHaveText("CRLF");
await status.click();
await expect(menu.getByRole("menuitemcheckbox", { name: windows, checked: true })).toBeFocused();
await page.keyboard.press("ArrowDown");
await page.keyboard.press("Enter");
await expect(status).toHaveText("LF");
await page.evaluate(async () => {
const path = "/src/platform/i18n.ts";
await (await import(/* @vite-ignore */ path)).setLocale("zh");
});
await status.click();
const translated = page.getByRole("menu", { name: "行分隔符", exact: true });
await expect(translated.getByRole("menuitem", { name: "Windows 换行 (\\r\\n)", exact: true })).toBeVisible();
});
test("status bar uses its row height and widget insets in both densities", async ({ workbench: page }) => {
const editor = await openFromTree(page, "build.gradle.kts");
const bar = page.locator('footer[aria-label="Status bar"]');
+4 -22
View File
@@ -71,15 +71,7 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 },
const search = terminal.getByRole("search", { name: "Find in terminal" });
const input = search.getByRole("textbox", { name: "Find in terminal" });
await input.fill("alpha");
const count = search.locator("[aria-live=polite]");
await expect(count).toHaveText(/\d+\/3/);
await expect(count).toHaveCSS("font-size", "13px");
const match = await count.textContent();
// The incremental search can report after the first Enter; retry until Enter moves on.
await expect(async () => {
await input.press("Enter");
await expect(count).not.toHaveText(match!, { timeout: 1000 });
}).toPass();
await expect(search.locator("[aria-live=polite]")).toHaveText(/\d+\/3/);
if (process.env.OPENIDEA_TERMINAL_SHOTS)
await terminal.screenshot({
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/terminal-${width}${split ? "-split" : ""}.png`,
@@ -91,19 +83,9 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 },
expect(rect.x).toBeGreaterThanOrEqual(bounds.x);
expect(rect.x + rect.width).toBeLessThanOrEqual(bounds.x + bounds.width + 1);
}
const matchCase = search.getByRole("button", { name: "Match Case", exact: true });
const inputBox = (await input.boundingBox())!;
if (width <= 280 || split) {
expect(inputBox.width).toBeGreaterThan(bounds.width * 0.62);
expect((await matchCase.boundingBox())!.y).toBeGreaterThan(inputBox.y + inputBox.height);
} else {
expect(inputBox.width).toBeGreaterThan(80);
}
const countBox = (await count.boundingBox())!;
const previousBox = (await search.getByRole("button", { name: "Previous Occurrence", exact: true }).boundingBox())!;
expect(previousBox.x - countBox.x - countBox.width).toBeLessThanOrEqual(4);
expect(countBox.y + countBox.height / 2).toBeCloseTo(previousBox.y + previousBox.height / 2, 0);
expect((await input.boundingBox())!.width).toBeGreaterThan(40);
const matchCase = search.getByRole("button", { name: "Match Case", exact: true });
await matchCase.focus();
await page.keyboard.press("Enter");
await expect(matchCase).toHaveAttribute("aria-pressed", "true");
@@ -148,7 +130,7 @@ test("wide terminal search leaves the grid in place and avoids covering the acti
const top = (await search.boundingBox())!;
expect(top.y).toBeCloseTo(before.y, 0);
expect(top.x + top.width).toBeCloseTo(before.x + before.width, 0);
expect(top.width).toBeLessThan(420);
expect(top.width).toBeLessThan(before.width);
await input.fill("right-edge");
await expect(search.locator("[aria-live=polite]")).toHaveText("1/1");
@@ -143,6 +143,10 @@
gap: var(--space-0-5);
padding: 0 6px 0 8px;
}
.pin {
color: var(--fg-muted);
margin-left: -2px;
}
.deprecated {
text-decoration-line: line-through;
}
+9 -3
View File
@@ -38,6 +38,7 @@ import { useFileColors } from "@/workbench/fileColors";
import { EmptyEditor } from "@/workbench/EditorArea";
import {
EmptyState,
Icon,
IconButton,
Menu,
SplitGroup,
@@ -215,6 +216,7 @@ function PaneView({ paneId }: { paneId: string }) {
? (gitRevisionOf(t.input.path)?.revision.slice(0, 8) ?? basename(dirname(t.input.path)))
: null;
const kindMark = tabTrailing(t.input, kinds);
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;
@@ -240,7 +242,6 @@ function PaneView({ paneId }: { paneId: string }) {
: tabIcon(t.input, kinds)
: undefined,
italic: t.preview,
pinned: t.pinned,
error: t.input.kind === "file" && errors[i],
modified: dirty[i],
// IDEA: hiding the close button is visual only. Keep close gestures
@@ -251,7 +252,13 @@ function PaneView({ paneId }: { paneId: string }) {
tints[i] || (fileColors && t.input.kind === "file" && t.input.path ? fileColors(t.input.path) : undefined),
tintStrength: tints[i] ? undefined : "var(--file-tint-strength)",
tooltip: virtualTooltip(t.input) ?? (showFullPathOnHover ? (t.input.path ?? name) : undefined),
trailing: kindMark,
trailing:
kindMark || pin ? (
<>
{kindMark}
{pin}
</>
) : undefined,
};
});
}, [
@@ -362,7 +369,6 @@ function PaneView({ paneId }: { paneId: string }) {
onSelect={(id) => ctrl.activate(paneId, id)}
onClose={(id) => void ctrl.closeTab(paneId, id)}
onCloseOthers={(id) => void ctrl.closeOthers(paneId, id)}
onTogglePin={(id) => ctrl.togglePin(paneId, id)}
closeOnShiftClick
onDoubleClick={(id) => {
// IDEA: a preview tab becomes a regular one; any other tab maximizes the editor.
+19 -5
View File
@@ -8,13 +8,12 @@
* Exclude with Preserve Case, Esc closes. `FindPanel` is the bar itself, for
* any CodeMirror view (the diff viewer's sides); `FindBar` is it on an editor pane.
*/
import { SearchHistoryMenu } from "@/ui/SearchHistoryMenu";
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
import { create } from "zustand";
import clsx from "clsx";
import type { EditorView } from "@codemirror/view";
import { Button, IconButton, Menu, SearchField, T, type MenuItem } from "@/ui";
import { SEARCH_CONTEXTS, rememberSearch } from "@/platform/search";
import { SEARCH_CONTEXTS, rememberSearch, searchHistory } from "@/platform/search";
import { editorController, useFindBars, useTabs } from "../controller";
import {
countMatches,
@@ -558,6 +557,19 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
? "0 results"
: `${count.current || "?"}/${count.total}${count.capped ? "+" : ""}`;
const historyItems = (kind: "find" | "replace"): MenuItem[] => {
const h = searchHistory(kind);
return h.length
? [
{ kind: "header", label: kind === "find" ? "Recent Searches" : "Recent Replacements" },
...h.map((q) => ({
label: q.replace(/\n/g, "⏎"),
verbatim: true,
run: () => setOpts(kind === "find" ? { search: q } : { replace: q }),
})),
]
: [{ label: kind === "find" ? "No recent searches" : "No recent replacements", disabled: true }];
};
const filterItems: MenuItem[] = [
{
label: "Search In Selection",
@@ -753,10 +765,12 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
</div>
</>
)}
<SearchHistoryMenu
kind={historyMenu}
<Menu
open={historyMenu !== null}
anchor={historyMenu === "replace" ? replaceBoxRef : findBoxRef}
onSelect={(value) => setOpts(historyMenu === "replace" ? { replace: value } : { search: value })}
items={historyMenu ? historyItems(historyMenu) : []}
placement="bottom-start"
aria-label="Recent searches"
onClose={() => setHistoryMenu(null)}
/>
<Menu
+6 -11
View File
@@ -417,11 +417,6 @@ export function CaretStatus() {
}
const EOL_LABEL: Record<LineEnding, string> = { lf: "LF", crLf: "CRLF", cr: "CR" };
const EOL_CHOICES: { id: LineEnding; label: string }[] = [
{ id: "crLf", label: "Windows (\\r\\n)" },
{ id: "lf", label: "Unix and macOS (\\n)" },
{ id: "cr", label: "Classic Mac OS (\\r)" },
];
export function LineEndingStatus() {
const meta = useActiveMeta();
@@ -459,12 +454,12 @@ export function LineEndingStatus() {
onClose={() => setOpen(false)}
anchor={ref}
placement="top-end"
title="Line Separator"
items={EOL_CHOICES.map(({ id, label }) => ({
id,
label,
checked: meta.lineEnding === id ? true : undefined,
run: () => choose(id),
aria-label="Line separator"
items={(["lf", "crLf", "cr"] as LineEnding[]).map((le) => ({
id: le,
label: `${EOL_LABEL[le]} – ${le === "lf" ? "Unix and macOS (\\n)" : le === "crLf" ? "Windows (\\r\\n)" : "Classic Mac OS (\\r)"}`,
checked: meta.lineEnding === le ? true : undefined,
run: () => choose(le),
}))}
/>
</>
-1
View File
@@ -1045,7 +1045,6 @@ const completionPopup = ViewPlugin.fromClass(
footer.className = "cm-lsp-completion-footer";
const tip = document.createElement("span");
tip.textContent = tx("Press ↵ to insert, ⇥ to replace");
tip.title = tip.textContent;
footer.append(tip, sortToggle(this.view));
}
// CodeMirror appends a fresh list when the candidates change.
+8 -21
View File
@@ -212,28 +212,22 @@ export const lspTheme = EditorView.theme({
color: "var(--fg-muted)",
},
".cm-lsp-completion-footer, .cm-lsp-inplace-footer": {
display: "flex",
flex: "none",
flexWrap: "wrap",
alignItems: "center",
padding: "5px 12px",
backgroundColor: "var(--bg-popup-inline, var(--bg-elev))",
color: "var(--fg-subtle)",
fontFamily: "var(--font-ui)",
fontSize: "var(--fs-small)",
gap: "var(--space-1) var(--space-3)",
justifyContent: "space-between",
borderRadius: "0 0 calc(var(--radius-popup) - 1px) calc(var(--radius-popup) - 1px)",
},
".cm-lsp-completion-footer": {
display: "grid",
gridTemplateColumns: "minmax(0, 1fr) minmax(0, max-content)",
gap: "var(--space-2)",
paddingBlock: "var(--space-1) 3px",
paddingInline: "var(--space-3) var(--space-2)",
},
".cm-lsp-completion-footer > span, .cm-lsp-completion-sort": {
minWidth: "0",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
},
".cm-lsp-completion-sort": {
flex: "none",
maxWidth: "100%",
padding: "0",
border: "none",
background: "none",
@@ -496,14 +490,7 @@ export const lspTheme = EditorView.theme({
'.cm-lsp-inplace-suggestions button[aria-current="true"]': {
backgroundColor: "var(--bg-list-selected, var(--bg-tree-selected, var(--bg-selected-strong)))",
},
".cm-lsp-inplace-footer": {
display: "flex",
flexWrap: "wrap",
padding: "5px 12px",
gap: "var(--space-1) var(--space-3)",
justifyContent: "space-between",
overflowWrap: "anywhere",
},
".cm-lsp-inplace-footer": { overflowWrap: "anywhere" },
// --- floating lightbulb (intentions.ts) -----------------------------------
".cm-lsp-bulb": {
+7 -21
View File
@@ -31,7 +31,6 @@ import {
mavenRoots,
nodeIcon,
nodeLabel,
pluginCoordinates,
profileChecked,
withGradleOptions,
gradleHasTestTask,
@@ -311,8 +310,6 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
</span>
);
}
const plugin = node.kind === "plugin" ? node.plugin : null;
const coordinates = plugin && `(${pluginCoordinates(plugin)})`;
const detail =
node.kind === "profiles" && node.projectRoot
? node.projectRoot.split("/").pop()
@@ -320,28 +317,18 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
? `(${node.dependency.scope}${node.dependency.optional ? ", optional" : ""})`
: node.kind === "dependency" && node.dependency.optional
? "(optional)"
: null;
: node.kind === "task"
? node.task.description
: null;
const skipped =
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
const label = (
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{plugin?.prefix ?? nodeLabel(node)}
</span>
);
return (
<span className={styles.row}>
<span className={styles.row} title={node.kind === "task" ? (node.task.description ?? undefined) : undefined}>
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
{coordinates ? (
<span className={styles.pluginText}>
{label}
<span className={styles.detail} title={coordinates}>
{coordinates}
</span>
</span>
) : (
label
)}
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{nodeLabel(node)}
</span>
{detail && <span className={styles.detail}>{detail}</span>}
</span>
);
@@ -488,7 +475,6 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
roots={roots}
getKey={(n) => n.key}
getLabel={nodeLabel}
getTooltip={(n) => (n.kind === "task" ? (n.task.description ?? undefined) : undefined)}
getChildren={getChildren}
isExpandable={(n) => !!getChildren(n)?.length}
expanded={expanded}
@@ -96,18 +96,6 @@
overflow: hidden;
text-overflow: ellipsis;
}
.pluginText {
display: flex;
align-items: center;
gap: var(--space-1-5);
min-width: 0;
overflow: hidden;
}
.pluginText > .label {
flex: none;
min-width: 0;
max-width: 100%;
}
.profile {
min-width: 0;
}
+3 -3
View File
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
return parts.join(":");
}
export function pluginCoordinates(p: MavenPlugin): string {
return `${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""}`;
export function pluginLabel(p: MavenPlugin): string {
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
}
/** Profile choices in different workspace members are independent. */
@@ -363,7 +363,7 @@ export function nodeLabel(node: BuildNode): string {
case "plugins":
return tx("Plugins");
case "plugin":
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
return pluginLabel(node.plugin);
case "goal":
return `${node.plugin.prefix}:${node.goal}`;
case "dependencies":
-30
View File
@@ -30,16 +30,6 @@
.strong {
color: var(--fg-strong);
}
.strong,
.rootDetail,
.directory {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.row > svg {
flex: none;
}
.selected {
color: var(--fg-strong);
}
@@ -47,26 +37,6 @@
flex: none;
color: var(--fg-subtle);
}
.rootDetail {
max-width: 50%;
}
.fileLabel {
display: flex;
min-width: 0;
gap: var(--space-1-5);
}
.fileName {
flex: none;
max-width: 100%;
}
.muted.directory {
flex: 0 1 auto;
}
.duration {
margin-inline-start: auto;
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
}
.fileIcon {
flex: none;
color: var(--fg-muted);
+12 -24
View File
@@ -67,12 +67,13 @@ function StatusIcon({ status }: { status: BuildStatus }) {
return <Icon name={name} size={14} className={styles[`status-${status}`]} />;
}
function rootDetail(status: BuildStatus, errors: number, warnings: number): string {
function rootDetail(status: BuildStatus, durationMs: number | null, errors: number, warnings: number): string {
if (status === "running") return "running…";
if (status === "cancelled") return "cancelled";
if (status === "success") return tx("Finished");
const summary = finishSummary({ success: false, errors, warnings, durationMs: null });
return summary.replace(/^Build failed:?\s*/, "") || "failed";
const summary = finishSummary({ success: status === "success", errors, warnings, durationMs });
return status === "success"
? `finished ${formatDuration(durationMs ?? 0)}`
: summary.replace(/^Build failed:?\s*/, "") || "failed";
}
export function BuildHeaderActions() {
@@ -129,19 +130,15 @@ function BuildTree() {
const renderNode = (n: BuildNode, state: TreeRowState) => {
if (n.kind === "root") {
const detail = rootDetail(n.status, n.errors, n.warnings);
const elapsed = n.status !== "running" && durationMs != null ? formatDuration(durationMs) : null;
return (
<span className={styles.row} title={[n.title, detail, elapsed].filter(Boolean).join(" ")}>
<span className={styles.row}>
<StatusIcon status={n.status} />
<span className={styles.strong}>{n.title}</span>
<span className={clsx(styles.muted, styles.rootDetail)}>{detail}</span>
{elapsed && <span className={clsx(styles.muted, styles.duration)}>{elapsed}</span>}
<span className={styles.muted}>{rootDetail(n.status, durationMs, n.errors, n.warnings)}</span>
</span>
);
}
if (n.kind === "file") {
const directory = relativeDir(root, n.path);
const errors = n.messages.filter((m) => m.severity === "error").length;
const warnings = n.messages.filter((m) => m.severity === "warning").length;
const counts = [
@@ -151,22 +148,13 @@ function BuildTree() {
.filter(Boolean)
.join(", ");
return (
<span className={styles.row} title={n.path}>
<span className={styles.row}>
<Icon name={fileIconName(basename(n.path), n.path)} size={16} className={styles.fileIcon} />
<span className={styles.fileLabel}>
<span
className={clsx(
styles.strong,
styles.fileName,
errors > 0 && styles.fileError,
state.selected && styles.selected,
)}
>
{basename(n.path)}
</span>
{directory && <span className={clsx(styles.muted, styles.directory)}>{directory}</span>}
<span className={clsx(styles.strong, errors > 0 && styles.fileError, state.selected && styles.selected)}>
{basename(n.path)}
</span>
{counts && <span className={styles.muted}>{counts}</span>}
<span className={styles.muted}>{relativeDir(root, n.path)}</span>
<span className={styles.muted}>{counts}</span>
</span>
);
}
@@ -2,8 +2,6 @@
display: flex;
align-items: center;
gap: var(--space-0-5);
flex: none;
}
.vertical {
flex-direction: column;
padding: 3px 6px;
flex-shrink: 0;
}
@@ -1,6 +1,4 @@
import { create } from "zustand";
import clsx from "clsx";
import { useTx } from "@/platform/i18n";
import { IconButton } from "@/ui";
import type { Usage } from "./usages";
import styles from "./UsageAccessFilter.module.css";
@@ -47,16 +45,11 @@ export function filterUsageAccess(items: readonly Usage[], options: UsageAccessO
export const supportsUsageAccess = (items: readonly Usage[]) => items.some((u) => u.access && u.access !== "unknown");
export function UsageAccessFilter({ items, vertical }: { items: readonly Usage[]; vertical?: boolean }) {
const tx = useTx();
export function UsageAccessFilter({ items }: { items: readonly Usage[] }) {
const options = useUsageAccessOptions();
if (!supportsUsageAccess(items)) return null;
return (
<div
className={clsx(styles.toolbar, vertical && styles.vertical)}
role={vertical ? "group" : "toolbar"}
aria-label={tx("Usage access filters")}
>
<div className={styles.toolbar} role="toolbar" aria-label="Usage access filters">
<IconButton
icon="show-read-access"
size="small"
+1 -1
View File
@@ -176,7 +176,6 @@ function UsagesPopupInner() {
</span>
</span>
<div className={styles.actions}>
<UsageAccessFilter items={all} />
{scope && (
<Select<UsageScope>
variant="ghost"
@@ -214,6 +213,7 @@ function UsagesPopupInner() {
</button>
</div>
</div>
<UsageAccessFilter items={all} />
{note && (
<div className={styles.note} data-testid="usages-note">
{note}
@@ -17,11 +17,8 @@
gap: var(--space-0-5);
padding: 4px 0;
border-right: 1px solid var(--border);
overflow-y: auto;
scrollbar-width: none;
}
.toolbarSep {
flex: none;
width: 16px;
height: 1px;
margin: 3px 0;
@@ -69,6 +66,7 @@
flex: 1;
min-height: 0;
}
.body > [role="toolbar"],
.body > .summary {
flex: 0 0 auto;
}
+1 -1
View File
@@ -284,11 +284,11 @@ export function UsagesView() {
<IconButton icon="arrow-up" action="navigate.prevOccurrence" size="small" iconSize={16} />
<IconButton icon="arrow-down" action="navigate.nextOccurrence" size="small" iconSize={16} />
<span className={styles.toolbarSep} />
<UsageAccessFilter items={allUsages} vertical />
<IconButton icon="expand-all" title="Expand All" size="small" iconSize={16} onClick={() => setAll(false)} />
<IconButton icon="collapse-all" title="Collapse All" size="small" iconSize={16} onClick={() => setAll(true)} />
</div>
<div className={styles.body} onKeyDown={onKeyDown}>
<UsageAccessFilter items={allUsages} />
{!search.loading && !search.error && search.scope === "project" && (
<div className={styles.summary}>
<T>Usages in Project Files</T>
@@ -53,7 +53,7 @@ it("shows a plain count for unclassified searches after a Java access mode was s
});
const view = render(<UsagesView />);
expect(screen.getByText("2 results")).toBeInTheDocument();
expect(screen.queryByRole("group", { name: "Usage access filters" })).toBeNull();
expect(screen.queryByRole("toolbar", { name: "Usage access filters" })).toBeNull();
view.unmount();
useUsageAccessOptions.setState({ read: true, write: true });
useUsages.setState({ tabs: [], active: null });
@@ -241,8 +241,7 @@ describe("MemoryView", () => {
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
const filter = screen.getByRole("textbox", { name: "筛选类" });
expect(filter.getAttribute("placeholder")).toBe("筛选类");
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
} finally {
await setLocale("en");
}
@@ -300,15 +299,10 @@ describe("MemoryView", () => {
expect(screen.getByText("Cache$Entry")).toBeTruthy();
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
const options = screen.getByRole("button", { name: "View Options" });
fireEvent.click(options);
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
expect(screen.getByText("Heap$Live")).toBeTruthy();
expect(screen.queryByText("Cache$Entry")).toBeNull();
expect(screen.queryByText("Dup")).toBeNull();
expect(options).toHaveAttribute("aria-pressed", "true");
fireEvent.click(options);
expect(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: true })).toBeInTheDocument();
});
it("sorts by the clicked column and reports it with aria-sort", async () => {
@@ -38,7 +38,7 @@ afterEach(() => {
describe("value hint", () => {
it("keeps a hint whose value was expanded past the hint's timeout", () => {
showHint(view, () => valueHint(view, "order", order, session), { pos: 0, timeout: 4000 });
showHint(view, () => valueHint("order", order, session), { pos: 0, timeout: 4000 });
expand();
expect(document.querySelector(".cm-lsp-hint .tree")).not.toBeNull();
vi.advanceTimersByTime(60_000);
@@ -47,7 +47,7 @@ describe("value hint", () => {
it("hands an expanded hover hint to its pin instead of growing in place", () => {
const pin = vi.fn();
showHint(view, () => valueHint(view, "order", order, session, 400, { pin }), { pos: 0 });
showHint(view, () => valueHint("order", order, session, 400, { pin }), { pos: 0 });
expand();
expect(pin).toHaveBeenCalled();
expect(document.querySelector(".tree")).toBeNull();
+8 -23
View File
@@ -169,25 +169,13 @@
/* Data Views › Show value tooltip on mouse hover. */
.valueTooltip {
display: flex;
align-items: flex-start;
gap: var(--space-1);
max-width: min(90vw, calc(var(--debug-value-editor-width, 100vw) - var(--space-2)));
padding: var(--space-1) var(--space-2);
font-family: var(--font-ui);
font-size: var(--fs-ui);
font-weight: 700;
line-height: 1.4;
}
.valueText {
min-width: 0;
max-width: 520px;
padding: 4px 8px;
font-family: var(--font-mono);
font-weight: var(--fw-code);
font-size: var(--fs-code);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.valueGlyph {
display: inline-flex;
flex: none;
margin-top: 1px;
word-break: break-word;
}
.valueTooltipTree {
display: flex;
@@ -206,22 +194,19 @@
padding: 0;
overflow: hidden;
}
:global(.cm-lsp-hint):has(> .valueTooltip) {
padding: 0;
}
.valueExpand {
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
flex: none;
margin-top: 1px;
margin-right: 4px;
padding: 0;
border: 0;
border-radius: var(--radius-small);
background: transparent;
color: var(--fg-muted);
vertical-align: -3px;
cursor: pointer;
}
.valueExpand:hover {
+2 -2
View File
@@ -49,7 +49,7 @@ class InlineValues extends WidgetType {
e.stopPropagation();
const session = activeSession();
if (!session || session.status !== "paused") return;
showHint(view, () => valueHint(view, part.name, part.variable, session.id, null), {
showHint(view, () => valueHint(part.name, part.variable, session.id, null), {
pos: view.posAtDOM(piece),
timeout: 60_000,
});
@@ -65,7 +65,7 @@ class InlineValues extends WidgetType {
e.stopPropagation();
const session = activeSession();
if (!session || session.status !== "paused") return;
showHint(view, () => valueHint(view, part.name, part.variable, session.id, null), {
showHint(view, () => valueHint(part.name, part.variable, session.id, null), {
pos: view.posAtDOM(show),
timeout: 60_000,
});
+26 -45
View File
@@ -13,7 +13,6 @@ import { activeSession, evaluate, useDebug } from "../state";
import { inlineValue, shownValue } from "../values";
import { tx } from "@/platform/i18n";
import { iconMarkup, selectableText } from "@/ui";
import { iconNode } from "@/ui/iconNode";
import { mountValueTree } from "../ui/ValueHintTree";
import styles from "./editor.module.css";
@@ -97,7 +96,6 @@ export function expressionAt(
/** IDEA's value hint: `expression = value {type}`, objects expandable into a variables tree in place. */
export function valueHint(
view: EditorView,
expression: string,
value: Variable,
session: DebugSessionId,
@@ -106,21 +104,15 @@ export function valueHint(
): { dom: HTMLElement; destroy: () => void } {
const dom = document.createElement("div");
dom.className = `${styles.valueTooltip} ${selectableText}`;
const stopSizing = watchHintWidth(view, dom);
let tree: { unmount(): void } | null = null;
const destroy = () => {
stopSizing();
tree?.unmount();
};
const expandTree = () => {
dom.classList.remove(styles.valueTooltip!);
dom.classList.replace(selectableText, styles.valueTooltipTree!);
dom.replaceChildren();
tree = mountValueTree(dom, expression, value, session);
};
if (value.variablesReference > 0 && opts.expanded) {
expandTree();
return { dom, destroy };
return { dom, destroy: () => tree?.unmount() };
}
if (value.variablesReference > 0) {
// IDEA's value hint: the "+" expands the object into a variables tree in place.
@@ -139,8 +131,6 @@ export function valueHint(
});
dom.append(expand);
}
const summary = document.createElement("span");
summary.className = styles.valueText!;
const name = document.createElement("span");
name.className = styles.valueName!;
name.textContent = `${expression} = `;
@@ -153,33 +143,11 @@ export function valueHint(
span.textContent = text;
return span;
};
summary.append(name);
if (leading) summary.append(type(`${shown.label} `));
summary.append(max === null ? shown.text : inlineValue(shown.text, max));
if (shown.label && !leading) summary.append(type(` ${shown.label}`));
dom.append(iconNode("variable", 16, styles.valueGlyph), summary);
return { dom, destroy };
}
function watchHintWidth(view: EditorView, dom: HTMLElement): () => void {
let width = 0;
let resizeFrame = 0;
const updateWidth = () => {
const next = view.dom.clientWidth;
if (!next || next === width) return;
width = next;
dom.style.setProperty("--debug-value-editor-width", `${width}px`);
};
updateWidth();
const resize = new ResizeObserver(() => {
cancelAnimationFrame(resizeFrame);
resizeFrame = requestAnimationFrame(updateWidth);
});
resize.observe(view.dom);
return () => {
resize.disconnect();
cancelAnimationFrame(resizeFrame);
};
dom.append(name);
if (leading) dom.append(type(`${shown.label} `));
dom.append(max === null ? shown.text : inlineValue(shown.text, max));
if (shown.label && !leading) dom.append(type(` ${shown.label}`));
return { dom, destroy: () => tree?.unmount() };
}
export function showQuickValue(
@@ -190,7 +158,7 @@ export function showQuickValue(
session: DebugSessionId,
) {
if (value.variablesReference > 0) showValueTree(view, pos, expression, value, session);
else showHint(view, () => valueHint(view, expression, value, session), { pos, timeout: 60_000 });
else showHint(view, () => valueHint(expression, value, session), { pos, timeout: 60_000 });
}
export function valueTooltip(): Extension {
@@ -217,7 +185,7 @@ export function valueTooltip(): Extension {
end: expr.to,
above: true,
create: (view) =>
valueHint(view, expr.text, value, session.id, 400, {
valueHint(expr.text, value, session.id, 400, {
// The tree outgrows the hint and may move to the other side of the line, away from the
// mouse, which closed the hover tooltip before it could be reached. Like IDEA's value
// popup it stays until Escape, a click in the editor or the next step.
@@ -240,7 +208,21 @@ function pinnedTree(view: EditorView, expression: string, value: Variable, sessi
const unsubscribe = useDebug.subscribe((s) => {
if (s.stopSeq !== stop || s.sessions[session]?.status !== "paused") hideHint(view);
});
const hint = valueHint(view, expression, value, session, 400, { expanded: true });
const hint = valueHint(expression, value, session, 400, { expanded: true });
let width = 0;
let resizeFrame = 0;
const updateWidth = () => {
const next = view.dom.clientWidth;
if (!next || next === width) return;
width = next;
hint.dom.style.setProperty("--debug-value-editor-width", `${width}px`);
};
updateWidth();
const resize = new ResizeObserver(() => {
cancelAnimationFrame(resizeFrame);
resizeFrame = requestAnimationFrame(updateWidth);
});
resize.observe(view.dom);
// The tree has the focus, so the editor's Escape doesn't reach the hint.
hint.dom.addEventListener("keydown", (e) => {
if (e.key !== "Escape" || e.defaultPrevented) return;
@@ -251,6 +233,8 @@ function pinnedTree(view: EditorView, expression: string, value: Variable, sessi
return {
dom: hint.dom,
destroy: () => {
resize.disconnect();
cancelAnimationFrame(resizeFrame);
unsubscribe();
hint.destroy();
},
@@ -303,10 +287,7 @@ export function selectionValueTooltip(): Extension {
}
// The selection moved on while evaluating.
if (seq !== this.seq) return;
showHint(this.view, () => valueHint(this.view, expr.text, value, session.id), {
pos: expr.from,
timeout: 60_000,
});
showHint(this.view, () => valueHint(expr.text, value, session.id), { pos: expr.from, timeout: 60_000 });
}
destroy() {
@@ -18,8 +18,8 @@
}
.filter {
flex: 1;
min-width: 0;
flex: 0 1 240px;
min-width: 80px;
}
.banner,
+8 -30
View File
@@ -1,7 +1,7 @@
/** Memory tab of the Debug tool window: live instance counts per class of the debugged JVM, and heap capture. */
import { useEffect, useMemo, useRef, useState } from "react";
import { useEffect, useMemo } from "react";
import clsx from "clsx";
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
import { executeAction } from "@/platform/actions";
import { useTx } from "@/platform/i18n";
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
@@ -112,8 +112,6 @@ export function MemoryView({ session }: { session: DebugSession }) {
const id = session.id;
const entry = useMemory((s) => s.bySession[id]);
const query = entry?.query ?? DEFAULT_QUERY;
const optionsButton = useRef<HTMLButtonElement>(null);
const [optionsOpen, setOptionsOpen] = useState(false);
const result = entry?.result ?? null;
const snapshot = entry?.snapshot ?? null;
const source = snapshot?.source ?? "histogram";
@@ -163,37 +161,17 @@ export function MemoryView({ session }: { session: DebugSession }) {
disabled={entry?.loading || !canRefresh}
/>
<HeapCaptureButton session={session} />
<SearchField
<Input
className={styles.filter}
value={query.filter}
onChange={(filter) => setMemoryQuery(id, { filter })}
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
placeholder="Filter classes"
aria-label="Filter classes"
/>
<IconButton
ref={optionsButton}
icon="settings"
title="View Options"
size="small"
iconSize={16}
pressed={query.changedOnly}
aria-haspopup="menu"
aria-expanded={optionsOpen}
onClick={() => setOptionsOpen(!optionsOpen)}
/>
<Menu
open={optionsOpen}
onClose={() => setOptionsOpen(false)}
anchor={optionsButton}
placement="bottom-end"
aria-label="View Options"
items={[
{
label: "Changed only",
checked: query.changedOnly,
run: () => setMemoryQuery(id, { changedOnly: !query.changedOnly }),
},
]}
<Checkbox
checked={query.changedOnly}
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
label="Changed only"
/>
</div>
{backend && (
+12 -55
View File
@@ -1,3 +1,7 @@
.spacer {
flex: 1;
}
.empty {
padding: 16px;
color: var(--fg-faint);
@@ -17,53 +21,12 @@
}
/* breakpoint popover */
.bpPopover {
display: flex;
flex-direction: column;
width: 400px;
overflow: hidden;
font-size: var(--fs-ui);
}
.bpPopoverTitle,
.bpFooter {
flex: none;
display: flex;
align-items: center;
gap: var(--space-2);
padding: var(--space-2) var(--space-3);
}
.bpPopoverTitle {
color: var(--fg-strong);
font-weight: 600;
white-space: nowrap;
}
.bpPopoverTitle > svg {
flex: none;
}
.bpPopoverTitle .bpFile {
font-family: var(--font-ui);
}
.bpPopoverFields {
.bpEditor {
width: 340px;
padding: 10px 12px;
display: flex;
flex-direction: column;
gap: var(--space-2);
min-height: 0;
padding: var(--space-1) var(--space-3) var(--space-2);
overflow: auto;
overscroll-behavior: contain;
}
.bpPopoverFields > * {
flex: none;
}
.bpPopoverFields .label {
font-size: var(--fs-ui);
}
.bpActions {
@@ -123,27 +86,21 @@
}
.bpFooter {
flex-wrap: wrap;
border-block-start: 1px solid var(--border-popup);
}
.bpFooterButtons {
display: flex;
flex-wrap: wrap;
gap: var(--space-1);
margin-inline-start: auto;
align-items: center;
gap: var(--space-1-5);
margin-top: 2px;
}
.bpMore {
.link {
display: inline-flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-1-5);
color: var(--accent);
font-size: var(--fs-ui);
cursor: pointer;
}
.bpMore:hover {
.link:hover {
color: var(--accent-hover);
}
+100 -113
View File
@@ -10,7 +10,6 @@ import {
type CSSProperties,
type KeyboardEvent,
type MutableRefObject,
type ReactNode,
} from "react";
import { basename, relativePath, useProject } from "@/platform/project";
import { executeAction, getAction } from "@/platform/actions";
@@ -138,62 +137,6 @@ function BreakpointPopover() {
return <BreakpointEditor key={popover.id} path={popover.path} bp={bp} at={popover} focusLog={popover.focusLog} />;
}
function BreakpointPropertiesPopup({
at,
title,
onClose,
onRemove,
children,
}: {
at: { x: number; y: number };
title: ReactNode;
onClose: () => void;
onRemove: () => void;
children: ReactNode;
}) {
return (
<Popup
open
onClose={onClose}
anchor={at}
placement="bottom-start"
trapFocus
aria-label="Breakpoint properties"
className={styles.bpPopover}
>
<div className={styles.bpPopoverTitle}>{title}</div>
<div className={styles.bpPopoverFields}>{children}</div>
<div className={styles.bpFooter}>
<button
type="button"
className={styles.bpMore}
onClick={() => {
onClose();
void executeAction("debug.viewBreakpoints");
}}
>
<T>More</T> <Kbd action="debug.viewBreakpoints" />
</button>
<div className={styles.bpFooterButtons}>
<Button
size="small"
variant="ghost"
onClick={() => {
onRemove();
closeBreakpointPopover();
}}
>
<T>Remove</T>
</Button>
<Button size="small" variant="primary" onClick={onClose}>
<T>Done</T>
</Button>
</div>
</div>
</Popup>
);
}
function BreakpointEditor({
path,
bp,
@@ -212,25 +155,49 @@ function BreakpointEditor({
};
return (
<BreakpointPropertiesPopup
at={at}
onClose={close}
onRemove={() => removeBreakpoint(path, bp.id)}
title={
<>
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
<div className={styles.bpEditor}>
<div className={styles.bpTitle}>
<span className={styles.bpDot} data-look={bp.enabled ? "on" : "off"} aria-hidden />
<BreakpointLocation path={path} line={bp.line} />
</>
}
>
<BreakpointFields
path={path}
bp={bp}
focus={focusLog ? "log" : "condition"}
onEnter={close}
commitRef={commitText}
/>
</BreakpointPropertiesPopup>
<span className={styles.bpFile}>
{basename(path)}:{bp.line + 1}
</span>
</div>
<BreakpointFields
path={path}
bp={bp}
focus={focusLog ? "log" : "condition"}
onEnter={close}
commitRef={commitText}
/>
<div className={styles.bpFooter}>
<button
type="button"
className={styles.link}
onClick={() => {
close();
void executeAction("debug.viewBreakpoints");
}}
>
<T>More</T> <Kbd action="debug.viewBreakpoints" />
</button>
<div className={styles.spacer} />
<Button
size="small"
variant="ghost"
onClick={() => {
removeBreakpoint(path, bp.id);
closeBreakpointPopover();
}}
>
<T>Remove</T>
</Button>
<Button size="small" variant="primary" onClick={close}>
<T>Done</T>
</Button>
</div>
</div>
</Popup>
);
}
@@ -398,46 +365,66 @@ function SpecialEditor({ bp, at }: { bp: SpecialBreakpoint; at: { x: number; y:
closeBreakpointPopover();
};
return (
<BreakpointPropertiesPopup
at={at}
onClose={close}
onRemove={() => removeSpecial(bp.id)}
title={
<>
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
<div className={styles.bpEditor}>
<div className={styles.bpTitle}>
<Icon name={bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
<span className={styles.bpFile} title={specialTitle(bp)}>
{specialTitle(bp)}
<span className={styles.bpFile}>{specialTitle(bp)}</span>
</div>
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
<label className={styles.field}>
<span className={styles.label}>
<T>Condition</T>
</span>
</>
}
>
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
<label className={styles.field}>
<span className={styles.label}>
<T>Condition</T>
</span>
<Input
mono
value={condition}
onChange={(e) => setCondition(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && close()}
data-autofocus=""
aria-label="Condition"
/>
</label>
<label className={styles.field}>
<span className={styles.label}>
<T>Hit count</T>
</span>
<Input
mono
value={hitCondition}
onChange={(e) => setHitCondition(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && close()}
aria-label="Hit count condition"
/>
</label>
</BreakpointPropertiesPopup>
<Input
mono
value={condition}
onChange={(e) => setCondition(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && close()}
data-autofocus=""
aria-label="Condition"
/>
</label>
<label className={styles.field}>
<span className={styles.label}>
<T>Hit count</T>
</span>
<Input
mono
value={hitCondition}
onChange={(e) => setHitCondition(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && close()}
aria-label="Hit count condition"
/>
</label>
<div className={styles.bpFooter}>
<button
type="button"
className={styles.link}
onClick={() => {
close();
void executeAction("debug.viewBreakpoints");
}}
>
<T>More</T> <Kbd action="debug.viewBreakpoints" />
</button>
<div className={styles.spacer} />
<Button
size="small"
variant="ghost"
onClick={() => {
removeSpecial(bp.id);
closeBreakpointPopover();
}}
>
<T>Remove</T>
</Button>
<Button size="small" variant="primary" onClick={close}>
<T>Done</T>
</Button>
</div>
</div>
</Popup>
);
}
@@ -1,25 +1,8 @@
.renameForm {
display: grid;
gap: var(--space-2);
padding: var(--space-3) var(--space-4);
}
.renameName {
display: grid;
gap: var(--space-1);
}
.renameOptions {
.form {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
gap: var(--space-2) var(--space-4);
overflow-wrap: anywhere;
}
.renameOptions > label {
min-width: 0;
max-width: 100%;
flex-direction: column;
gap: var(--space-2);
padding: 14px;
}
.refactorForm {
@@ -143,7 +143,7 @@ function Options({
disabled: boolean;
}) {
return (
<div className={move ? styles.options : styles.renameOptions}>
<div className={styles.options}>
<Checkbox
label="Search for references"
checked={value.references}
@@ -223,33 +223,31 @@ function RenameDialog({ request }: { request: Extract<FileRefactorRequest, { kin
]}
>
<form
className={styles.renameForm}
className={styles.form}
onSubmit={(e) => {
e.preventDefault();
submit();
}}
>
<div className={styles.renameName}>
<label className={styles.fieldLabel} htmlFor="file-rename-name">
{request.dir
? tx`Rename directory '${current}' and its usages to:`
: tx`Rename file '${current}' and its usages to:`}
</label>
<Input
id="file-rename-name"
ref={input}
value={name}
disabled={busy}
invalid={!!error}
aria-label="New name"
onChange={(e) => setName(e.target.value)}
/>
{error && (
<div className={styles.error} role="alert">
{error}
</div>
)}
</div>
<label className={styles.fieldLabel} htmlFor="file-rename-name">
{request.dir
? tx`Rename directory '${current}' and its usages to:`
: tx`Rename file '${current}' and its usages to:`}
</label>
<Input
id="file-rename-name"
ref={input}
value={name}
disabled={busy}
invalid={!!error}
aria-label="New name"
onChange={(e) => setName(e.target.value)}
/>
{error && (
<div className={styles.error} role="alert">
{error}
</div>
)}
<Options value={options} onChange={setOptions} move={false} disabled={busy} />
</form>
</Dialog>
+14 -25
View File
@@ -1,17 +1,6 @@
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
import { useMemo, useState, type KeyboardEvent } from "react";
import clsx from "clsx";
import {
HighlightedText,
Icon,
List,
Popup,
SearchField,
firstSelectable,
fuzzyMatch,
listNavigate,
T,
type PopupAnchor,
} from "@/ui";
import { HighlightedText, Icon, List, Popup, SearchField, fuzzyMatch, listNavigate, T, type PopupAnchor } from "@/ui";
import { useRowHeight } from "@/ui/density";
import { useRunConfigTypes, runConfigTypes, type RunConfigTypeContribution } from "@/workbench/contributions";
import styles from "./Run.module.css";
@@ -75,11 +64,12 @@ export function AddConfigPopup({
const [query, setQuery] = useState("");
const rows = useMemo(() => typeRows(runConfigTypes(types), query), [types, query]);
const isSection = (r: TypeRow) => r.kind === "group";
const [active, setActive] = useState(-1);
const first = Math.max(
0,
rows.findIndex((r) => r.kind === "type"),
);
const [active, setActive] = useState(first);
const clamped = Math.min(active, rows.length - 1);
const selected = rows[clamped]?.kind === "type" ? clamped : firstSelectable(rows, isSection);
const viewport = useRef<HTMLDivElement>(null);
const height = Math.max(1, Math.min(rows.length, 30)) * rowHeight;
const pick = (row: TypeRow | undefined) => {
if (row?.kind !== "type") return;
@@ -90,11 +80,10 @@ export function AddConfigPopup({
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "Enter") {
e.preventDefault();
pick(rows[selected]);
pick(rows[clamped]);
return;
}
const pageSize = Math.max(1, Math.floor((viewport.current?.clientHeight ?? height) / rowHeight) - 1);
const next = listNavigate(e.key, { items: rows, active: selected, isSection, pageSize, wrap: true });
const next = listNavigate(e.key, { items: rows, active: clamped, isSection, wrap: true });
if (next !== null) {
e.preventDefault();
setActive(next);
@@ -108,7 +97,7 @@ export function AddConfigPopup({
onClose={onClose}
placement="bottom-start"
aria-label="Add New Configuration"
className={clsx(styles.chooser, styles.typeChooser)}
className={styles.chooser}
trapFocus
>
<div className={styles.chooserCaption}>
@@ -119,7 +108,7 @@ export function AddConfigPopup({
value={query}
onChange={(v) => {
setQuery(v);
setActive(-1);
setActive(0);
}}
placeholder="Search types"
aria-label="Search configuration types"
@@ -128,7 +117,7 @@ export function AddConfigPopup({
variant="bare"
/>
</div>
<div ref={viewport} className={styles.chooserViewport} style={{ height }}>
<div style={{ height: Math.max(rowHeight, Math.min(rows.length * rowHeight, 14 * rowHeight)) }}>
<List<TypeRow>
aria-label="Configuration types"
className={styles.chooserList}
@@ -136,7 +125,7 @@ export function AddConfigPopup({
getKey={(r) => r.key}
isSection={isSection}
renderSection={(r) => (r.kind === "group" ? r.label : null)}
activeIndex={selected}
activeIndex={rows[clamped]?.kind === "type" ? clamped : first}
onActiveChange={setActive}
focusable={false}
hoverSelects
@@ -150,7 +139,7 @@ export function AddConfigPopup({
renderItem={(r) =>
r.kind === "type" ? (
<span className={clsx(styles.chooserRow, r.nested && styles.typeNested)} title={r.type.description}>
<Icon name={r.type.icon} size={16} className={styles.chooserIcon} />
<Icon name={r.type.icon} size={13} className={styles.chooserIcon} />
<span className={styles.chooserName}>
{r.indices?.length ? <HighlightedText text={r.type.label} indices={r.indices} /> : r.type.label}
</span>
+57 -118
View File
@@ -6,16 +6,7 @@
import { writeClipboardText } from "@/platform/clipboard";
import { isJvmApplication, parseJavaArgs } from "@/platform/javaLaunch";
import { useRunTargets } from "@/platform/pluginRunTargets";
import {
useEffect,
useMemo,
useRef,
useState,
type KeyboardEvent,
type MouseEvent,
type ReactNode,
type RefObject,
} from "react";
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode, type RefObject } from "react";
import clsx from "clsx";
import { isTauri, type BeforeLaunchTask, type BuildPolicy, type RunConfig } from "@/platform/ipc";
import { useWorkflowSettings } from "@/platform/workflowSettings";
@@ -63,16 +54,6 @@ import { TomcatSettings } from "./TomcatSettings";
import { toolWindowTitle } from "@/workbench/toolwindows/title";
import styles from "./Run.module.css";
const TASK_ICONS: Readonly<Partial<Record<string, string>>> = {
build: "build-project",
buildModule: "build-project",
buildArtifacts: "build-rebuild",
dotnetBuild: "build-project",
run: "run",
tool: "settings",
command: "terminal",
};
/**
* Debug adapters with a real launch template (`debugger/launch.ts`, `debugger/java.ts`),
* verified against small programs. Others (dart, …) only got
@@ -351,7 +332,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
const [envOpen, setEnvOpen] = useState(false);
const [modifyOpen, setModifyOpen] = useState(false);
const [lastRequest, setLastRequest] = useState(modifyRequest);
const [taskMenu, setTaskMenu] = useState<"add" | { index: number; anchor: HTMLButtonElement } | null>(null);
const [taskMenu, setTaskMenu] = useState(false);
const modifyRef = useRef<HTMLButtonElement>(null);
const taskRef = useRef<HTMLButtonElement>(null);
@@ -425,23 +406,23 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
run: () => addTask("run", c.id),
})),
},
{ label: TASK_LABELS.build, icon: TASK_ICONS.build, run: () => addTask("build") },
{ label: TASK_LABELS.build, icon: "build-project", run: () => addTask("build") },
{
label: TASK_LABELS.buildModule,
icon: TASK_ICONS.buildModule,
icon: "build-project",
disabled: config.module == null,
run: () => addTask("buildModule", config.module ?? ""),
},
{ label: TASK_LABELS.buildArtifacts, icon: TASK_ICONS.buildArtifacts, run: () => addTask("buildArtifacts") },
{ label: TASK_LABELS.buildArtifacts, icon: "build-rebuild", run: () => addTask("buildArtifacts") },
...(config.kind === "dotnet"
? [{ label: TASK_LABELS.dotnetBuild, icon: TASK_ICONS.dotnetBuild, run: () => addTask("dotnetBuild") }]
? [{ label: TASK_LABELS.dotnetBuild, icon: "build-project", run: () => addTask("dotnetBuild") }]
: []),
{
label: TASK_LABELS.tool,
disabled: !externalTools.length,
submenu: externalTools.map((t) => ({ label: t.name, verbatim: true, run: () => addTask("tool", t.id) })),
},
{ label: TASK_LABELS.command, icon: TASK_ICONS.command, run: () => addTask("command") },
{ label: TASK_LABELS.command, icon: "terminal", run: () => addTask("command") },
{
label: TASK_LABELS.toolWindow,
submenu: [...toolWindows.values()]
@@ -461,7 +442,6 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
[next[i], next[j]] = [next[j]!, next[i]!];
setTasks(next);
};
const taskActions = taskMenu === "add" ? null : taskMenu;
const adapterOptions: SelectOption[] = [
{ value: "", label: "None" },
@@ -783,103 +763,62 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
{isShown("beforeLaunch") && (
<Field label="Before launch" error={errors.beforeLaunch} top>
<div className={styles.beforeLaunchTasks} role="list" aria-label={tx("Before launch tasks")}>
{tasks.map((t, i) => {
const label = txTemplate(taskLabel(t, all));
const target = t.kind === "run" ? all.find((c) => c.id === t.target) : undefined;
const icon = target ? configIcon(target) : TASK_ICONS[t.kind];
const prefix = (
<>
{icon && <Icon name={icon} size={14} />}
<span className={styles.taskOrder}>{i + 1}.</span>
</>
);
const actions = {
"aria-haspopup": "menu" as const,
"aria-expanded": taskActions?.index === i,
onClick: (e: MouseEvent<HTMLButtonElement>) => setTaskMenu({ index: i, anchor: e.currentTarget }),
};
return (
<div key={i} role="listitem" className={styles.taskTag}>
{t.kind === "command" ? (
<>
{prefix}
<Input
mono
className={styles.taskCommand}
aria-label={txTemplate(`Before launch command ${i + 1}`)}
value={t.target ?? ""}
placeholder="Shell command, e.g. make generate"
onChange={(e) =>
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
}
/>
<IconButton icon="more" title="Task Actions" size="small" {...actions} />
</>
) : (
<button type="button" className={styles.taskName} title={label} {...actions}>
{prefix}
<span className={styles.taskLabel}>{label}</span>
</button>
)}
<div className={styles.taskList} role="list" aria-label={tx("Before launch tasks")}>
{tasks.map((t, i) => (
<div key={i} role="listitem" className={styles.taskRow}>
{t.kind === "command" ? (
<Input
mono
aria-label={txTemplate(`Before launch command ${i + 1}`)}
value={t.target ?? ""}
placeholder="Shell command, e.g. make generate"
onChange={(e) =>
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
}
/>
) : (
<span className={styles.taskLabel} title={txTemplate(taskLabel(t, all))}>
{txTemplate(taskLabel(t, all))}
</span>
)}
<span className={styles.taskActions}>
<IconButton
icon="close"
icon="arrow-up"
size="small"
iconSize={12}
title="Move Up"
disabled={i === 0}
onClick={() => moveTask(i, -1)}
/>
<IconButton
icon="arrow-down"
size="small"
iconSize={12}
title="Move Down"
disabled={i === tasks.length - 1}
onClick={() => moveTask(i, 1)}
/>
<IconButton
icon="minus"
size="small"
iconSize={12}
title="Remove Task"
onClick={() => setTasks(tasks.filter((_, j) => j !== i))}
/>
</div>
);
})}
<div role="listitem">
{tasks.length ? (
<IconButton
ref={taskRef}
title="Add task"
icon="plus"
size="small"
aria-haspopup="menu"
aria-expanded={taskMenu === "add"}
onClick={() => setTaskMenu("add")}
/>
) : (
<Button
ref={taskRef}
size="small"
variant="ghost"
icon="plus"
aria-haspopup="menu"
aria-expanded={taskMenu === "add"}
onClick={() => setTaskMenu("add")}
>
<T>Add task</T>
</Button>
)}
</div>
<Menu open={taskMenu === "add"} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(null)} />
{taskActions && (
<Menu
open
anchor={taskActions.anchor}
aria-label={tx("Task Actions")}
items={[
{
label: "Move Up",
icon: "arrow-up",
disabled: taskActions.index === 0,
run: () => moveTask(taskActions.index, -1),
},
{
label: "Move Down",
icon: "arrow-down",
disabled: taskActions.index === tasks.length - 1,
run: () => moveTask(taskActions.index, 1),
},
]}
onClose={() => setTaskMenu(null)}
/>
)}
</span>
</div>
))}
<Button
ref={taskRef}
size="small"
variant="ghost"
icon="plus"
aria-haspopup="menu"
onClick={() => setTaskMenu(true)}
>
<T>Add task</T>
</Button>
<Menu open={taskMenu} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(false)} />
</div>
</Field>
)}
+34 -64
View File
@@ -1,8 +1,7 @@
import { useRef, useState, type RefObject } from "react";
import { useState } from "react";
import clsx from "clsx";
import { useTx } from "@/platform/i18n";
import { isImeKey } from "@/platform/ime";
import { Button, IconButton, Popup } from "@/ui";
import { Dialog, IconButton } from "@/ui";
import styles from "./Run.module.css";
/**
@@ -26,10 +25,9 @@ export function ExpandableTextarea({
onChange: (value: string) => void;
}) {
const tx = useTx();
const fieldRef = useRef<HTMLDivElement>(null);
const [expanded, setExpanded] = useState(false);
return (
<div ref={fieldRef} className={styles.textareaWithButton}>
<div className={styles.textareaWithButton}>
<textarea
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
aria-label={tx(label)}
@@ -45,86 +43,58 @@ export function ExpandableTextarea({
}
}}
/>
<IconButton
icon="expand-all"
size="small"
iconSize={14}
title="Expand (⇧⏎)"
aria-haspopup="dialog"
aria-expanded={expanded}
onClick={() => setExpanded(!expanded)}
/>
<IconButton icon="expand-all" size="small" iconSize={14} title="Expand (⇧⏎)" onClick={() => setExpanded(true)} />
{expanded && (
<ExpandedTextPopup
anchor={fieldRef}
label={tx(label)}
value={value}
onOk={onChange}
onClose={() => setExpanded(false)}
/>
<ExpandedTextDialog label={label} value={value} onOk={onChange} onClose={() => setExpanded(false)} />
)}
</div>
);
}
function ExpandedTextPopup({
anchor,
function ExpandedTextDialog({
label,
value,
onOk,
onClose,
}: {
anchor: RefObject<HTMLDivElement | null>;
label: string;
value: string;
onOk: (value: string) => void;
onClose: () => void;
}) {
const tx = useTx();
const [text, setText] = useState(value);
const apply = () => {
if (text !== value) onOk(text);
onClose();
};
return (
<Popup
<Dialog
open
anchor={anchor}
aria-label={label}
className={styles.expandedEditor}
title={tx(label)}
onClose={onClose}
trapFocus
matchWidth
closeOnDeactivate={false}
width={720}
resizable="both"
minWidth={240}
minHeight={160}
minWidth={360}
minHeight={220}
buttons={[
{
label: "OK",
role: "default",
onClick: () => {
if (text !== value) onOk(text);
onClose();
},
},
{ label: "Cancel", role: "cancel" },
]}
>
<div
className={styles.expandedEditorBody}
onKeyDown={(e) => {
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || isImeKey(e.nativeEvent))
return;
e.preventDefault();
e.stopPropagation();
apply();
}}
>
<textarea
className={clsx(styles.textarea, styles.expandedTextarea)}
aria-label={label}
spellCheck={false}
wrap="off"
value={text}
data-autofocus
onChange={(e) => setText(e.target.value)}
/>
<div className={styles.expandedEditorActions}>
<Button onClick={onClose}>Cancel</Button>
<Button variant="primary" onClick={apply}>
OK
</Button>
</div>
</div>
</Popup>
<textarea
className={clsx(styles.textarea, styles.expandedTextarea)}
aria-label={tx(label)}
spellCheck={false}
wrap="off"
rows={14}
value={text}
autoFocus
onChange={(e) => setText(e.target.value)}
/>
</Dialog>
);
}
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { commands } from "@/platform/ipc";
import { ExportTestResultsDialog, defaultExportName, loadExportOptions } from "./ExportTestResultsDialog";
import { ExportTestResultsDialog, defaultExportPath, loadExportOptions } from "./ExportTestResultsDialog";
import { TestResults } from "./testing";
const actions = vi.hoisted(() => ({ executeAction: vi.fn(async () => {}) }));
@@ -56,15 +56,13 @@ function open(onClose = vi.fn()) {
return onClose;
}
const file = () => screen.getByLabelText("File name");
const folder = () => screen.getByLabelText("Folder");
const file = () => screen.getByLabelText("Output file");
const press = (name: string) => fireEvent.click(screen.getByRole("button", { name }));
describe("ExportTestResultsDialog", () => {
it("writes an HTML report to the project folder and opens it in the browser", async () => {
it("writes an HTML report to the project folder under IDEA's name and opens it in the browser", async () => {
const onClose = open();
expect(file()).toHaveValue("Test Results - go test _calc.html");
expect(folder()).toHaveValue("/work/app/");
expect(file()).toHaveValue("/work/app/Test Results - go test _calc.html");
expect(screen.getByRole("radio", { name: "HTML" })).toBeChecked();
press("OK");
await waitFor(() => expect(onClose).toHaveBeenCalled());
@@ -94,7 +92,7 @@ describe("ExportTestResultsDialog", () => {
it("switches the extension with the format, keeps XML out of the browser, and remembers the choice", async () => {
const onClose = open();
fireEvent.click(screen.getByRole("radio", { name: "XML" }));
expect(file()).toHaveValue("Test Results - go test _calc.xml");
expect(file()).toHaveValue("/work/app/Test Results - go test _calc.xml");
// Only an HTML report opens in the browser.
expect(screen.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled();
press("OK");
@@ -145,36 +143,18 @@ describe("ExportTestResultsDialog", () => {
});
it("doesn't ask again for a file the save dialog already confirmed", async () => {
const path = "C:\\reports\\picked.html";
onDisk[path] = "file";
dialog.save.mockResolvedValueOnce(path);
onDisk["/tmp/picked.html"] = "file";
dialog.save.mockResolvedValueOnce("/tmp/picked.html");
const onClose = open();
press("Browse…");
await waitFor(() => expect(file()).toHaveValue("picked.html"));
expect(folder()).toHaveValue("C:\\reports\\");
await waitFor(() => expect(file()).toHaveValue("/tmp/picked.html"));
expect(dialog.save).toHaveBeenCalledWith(
expect.objectContaining({
defaultPath: "/work/app/Test Results - go test _calc.html",
filters: [{ name: "HTML", extensions: ["html"] }],
}),
expect.objectContaining({ filters: [{ name: "HTML", extensions: ["html"] }] }),
);
press("OK");
await waitFor(() => expect(onClose).toHaveBeenCalled());
expect(messages.confirm).not.toHaveBeenCalled();
expect(written.map((w) => w.path)).toEqual([path]);
});
it("confirms again when the destination changes after using the save dialog", async () => {
dialog.save.mockResolvedValueOnce("/tmp/picked.html");
onDisk["/work/app/reports/picked.html"] = "file";
messages.confirm.mockResolvedValueOnce(false);
open();
press("Browse…");
await waitFor(() => expect(file()).toHaveValue("picked.html"));
fireEvent.change(folder(), { target: { value: "reports" } });
press("OK");
await waitFor(() => expect(messages.confirm).toHaveBeenCalledOnce());
expect(written).toHaveLength(0);
expect(written.map((w) => w.path)).toEqual(["/tmp/picked.html"]);
});
it("reports a directory or a failed write and stays open", async () => {
@@ -207,11 +187,15 @@ describe("ExportTestResultsDialog", () => {
});
});
describe("defaultExportName", () => {
describe("defaultExportPath", () => {
it("replaces characters file systems refuse in the configuration's name", () => {
expect(defaultExportName('a/b\\c:d*e?f"g<h>i|j', "xml")).toBe("Test Results - a_b_c_d_e_f_g_h_i_j.xml");
expect(defaultExportName("go test ./...", "html")).toBe("Test Results - go test.html");
expect(defaultExportName("Tests in 'com.acme.Cart'", "html")).toBe("Test Results - Tests in 'com_acme_Cart'.html");
expect(defaultExportName("...", "html")).toBe("Test Results - Tests.html");
expect(defaultExportPath("C:\\proj\\", 'a/b\\c:d*e?f"g<h>i|j', "xml")).toBe(
"C:\\proj/Test Results - a_b_c_d_e_f_g_h_i_j.xml",
);
expect(defaultExportPath("/p", "go test ./...", "html")).toBe("/p/Test Results - go test.html");
expect(defaultExportPath("/p", "Tests in 'com.acme.Cart'", "html")).toBe(
"/p/Test Results - Tests in 'com_acme_Cart'.html",
);
expect(defaultExportPath("/p", "...", "html")).toBe("/p/Test Results - Tests.html");
});
});
+33 -75
View File
@@ -2,7 +2,7 @@
* IDEA's Export Test Results dialog: HTML or XML, the output file, and whether to
* open an HTML report in the browser once it is written.
*/
import { useId, useState } from "react";
import { useState } from "react";
import { executeAction } from "@/platform/actions";
import { tx } from "@/platform/i18n";
import { call, commands } from "@/platform/ipc";
@@ -38,35 +38,13 @@ function saveExportOptions(o: ExportOptions) {
}
}
/** Runs of dots and characters file systems refuse become one `_`. */
export function defaultExportName(name: string, format: TestExportFormat): string {
/**
* IDEA's default name, `Test Results - <configuration>.html`. Like IDEA's `PathUtil.suggestFileName`, runs of
* dots and characters file systems refuse become one `_` (`go test ./...` gives `go test`).
*/
export function defaultExportPath(dir: string, name: string, format: TestExportFormat): string {
const safe = name.replace(/[/\\:*?"<>|.]+/g, "_").replace(/^[\s_]+|[\s_]+$/g, "");
return `Test Results - ${safe || "Tests"}.${format}`;
}
interface Destination {
folder: string;
fileName: string;
/** The native picker already asked before replacing this exact path. */
pickedPath?: string;
}
function destinationFromPicker(path: string): Destination {
const slash = path.lastIndexOf("/");
const posix = path.startsWith("/") && !path.startsWith("//");
const end = (posix ? slash : Math.max(slash, path.lastIndexOf("\\"))) + 1;
return { folder: path.slice(0, end), fileName: path.slice(end), pickedPath: path };
}
function resolveDestination({ folder, fileName, pickedPath }: Destination, cwd: string): string {
if (pickedPath) return pickedPath;
const file = fileName.trim();
if (!file || isAbsolutePath(file)) return file;
const dir = folder.trim();
const posix = dir.startsWith("/") && !dir.startsWith("//");
const base = dir.replace(posix ? /\/+$/ : /[\\/]+$/, "");
const path = dir ? `${base}/${file}` : file;
return isAbsolutePath(path) ? path : `${cwd.replace(/[\\/]+$/, "")}/${path}`;
return `${dir.replace(/[\\/]+$/, "")}/Test Results - ${safe || "Tests"}.${format}`;
}
async function exists(path: string): Promise<"file" | "dir" | null> {
@@ -133,47 +111,44 @@ export function ExportTestResultsDialog({
cwd: string;
onClose: () => void;
}) {
const fileNameId = useId();
const folderId = useId();
const [options, setOptions] = useState(loadExportOptions);
const [destination, setDestination] = useState<Destination>(() => ({
folder: cwd,
fileName: defaultExportName(name, options.format),
}));
const [path, setPath] = useState(() => defaultExportPath(cwd, name, options.format));
// The save dialog already asked before replacing this file.
const [picked, setPicked] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const html = options.format === "html";
const { folder, fileName, pickedPath } = destination;
const target = resolveDestination(destination, cwd);
const update = (next: Partial<ExportOptions>) => {
const merged = { ...options, ...next };
setOptions(merged);
saveExportOptions(merged);
// The file follows the format's extension, as in the Export Data dialog.
if (next.format) {
const nextName = fileName.replace(/\.(html|xml)$/i, `.${next.format}`);
if (nextName !== fileName) setDestination({ folder, fileName: nextName });
}
if (next.format) setPath((p) => p.replace(/\.(html|xml)$/i, `.${next.format}`));
};
const browse = async () => {
try {
const { save } = await import("@/platform/dialog");
const chosen = await save({
defaultPath: target || folder || cwd,
defaultPath: path,
filters: [{ name: html ? "HTML" : "XML", extensions: [options.format] }],
});
if (chosen) setDestination(destinationFromPicker(chosen));
if (chosen) {
setPath(chosen);
setPicked(chosen);
}
} catch {
// No dialog (tests): keep typing the path.
}
};
const run = async () => {
if (!target) return;
const raw = path.trim();
if (!raw) return;
const target = isAbsolutePath(raw) ? raw : `${cwd.replace(/[\\/]+$/, "")}/${raw}`;
setBusy(true);
const text = exportTestResults(options.format, results, { name, cwd, date: new Date() });
const ok = await writeTestReport(target, text, pickedPath !== undefined);
const ok = await writeTestReport(target, text, picked === raw);
setBusy(false);
if (!ok) return;
onClose();
@@ -192,46 +167,29 @@ export function ExportTestResultsDialog({
open
title="Export Test Results"
onClose={onClose}
width={500}
width={520}
buttons={[
{ label: "OK", role: "default", disabled: busy || !target, onClick: () => void run() },
{ label: "OK", role: "default", disabled: busy || !path.trim(), onClick: () => void run() },
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.exportReport}>
<fieldset className={styles.exportFormats} role="radiogroup">
<legend>
<div className={styles.dialogBody}>
<div className={styles.exportFormats} role="radiogroup" aria-label="Export format">
<span>
<T>Export format:</T>
</legend>
</span>
<Radio name="test-export-format" label="HTML" checked={html} onChange={() => update({ format: "html" })} />
<Radio name="test-export-format" label="XML" checked={!html} onChange={() => update({ format: "xml" })} />
</fieldset>
<fieldset className={styles.exportOutput}>
<legend>
<T>Output</T>
</legend>
<label htmlFor={fileNameId}>
<T>File name</T>
</label>
<Input
id={fileNameId}
autoSelect
data-autofocus=""
value={fileName}
onChange={(e) => setDestination({ folder, fileName: e.target.value })}
/>
<label htmlFor={folderId}>
<T>Folder</T>
</label>
</div>
<label className={styles.exportField}>
<span>
<T>Output file:</T>
</span>
<div className={styles.inputWithButton}>
<Input
id={folderId}
value={folder}
onChange={(e) => setDestination({ folder: e.target.value, fileName })}
/>
<Input mono aria-label="Output file" value={path} onChange={(e) => setPath(e.target.value)} />
<IconButton icon="folder" title="Browse…" onClick={() => void browse()} />
</div>
</fieldset>
</label>
<Checkbox
checked={html && options.openInBrowser}
disabled={!html}
+17 -107
View File
@@ -560,17 +560,6 @@
color: var(--fg-secondary);
font-weight: 500;
}
.typeChooser {
width: 280px;
}
.typeChooser .chooserCaption {
padding: var(--space-2) var(--space-3) 0;
color: var(--fg-strong);
font-weight: 600;
}
.typeChooser .chooserSearch {
padding: var(--space-1) var(--space-3);
}
.chooserMnemonic {
flex: none;
width: 8px;
@@ -922,44 +911,28 @@
outline: none;
}
.textareaWithButton {
position: relative;
display: flex;
align-items: flex-start;
gap: var(--space-1-5);
min-width: 0;
}
.textareaWithButton > textarea {
display: block;
width: 100%;
padding-inline-end: calc(var(--space-3) + var(--space-4));
flex: 1;
min-width: 0;
}
.textareaWithButton > button {
position: absolute;
inset-block-start: var(--space-1);
inset-inline-end: var(--space-1);
}
.expandedEditor {
width: 512px;
height: 272px;
}
.expandedEditorBody {
display: flex;
flex-direction: column;
height: 100%;
padding: var(--space-2);
gap: var(--space-2);
flex-shrink: 0;
}
/* One visual line per line of text: a long argument scrolls instead of wrapping. */
.expandedTextarea {
flex: 1;
min-height: 0;
width: 100%;
height: 100%;
min-height: 160px;
box-sizing: border-box;
resize: none;
white-space: pre;
overflow: auto;
}
.expandedEditorActions {
display: flex;
justify-content: flex-end;
flex: none;
gap: var(--space-2);
}
.textarea:focus {
box-shadow: inset 0 0 0 1px var(--focus-ring);
}
@@ -985,43 +958,10 @@
.taskRow > :first-child {
min-width: 0;
}
.beforeLaunchTasks {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-1);
}
.taskTag {
.taskActions {
display: inline-flex;
align-items: center;
gap: var(--space-1);
min-width: 0;
max-width: 100%;
min-height: var(--h-list-row);
padding-inline: var(--space-2) var(--space-1);
border-radius: var(--radius-small);
background: var(--bg-elev);
color: var(--fg);
font-size: var(--fs-ui);
}
.taskName {
display: inline-flex;
align-items: center;
gap: var(--space-1);
min-width: 0;
min-height: var(--h-list-row);
text-align: start;
}
.taskName:hover {
color: var(--fg-strong);
}
.taskOrder {
flex: none;
color: var(--fg-muted);
}
.taskTag .taskCommand {
width: 24ch;
height: var(--h-control-small);
gap: var(--space-0-5);
}
.taskLabel {
overflow: hidden;
@@ -1194,48 +1134,18 @@
gap: var(--space-2);
padding: 12px 16px;
}
.exportReport {
display: flex;
flex-direction: column;
gap: var(--space-3);
padding: var(--space-3) var(--space-4) var(--space-1);
font-size: var(--fs-ui);
}
.exportFormats,
.exportOutput {
min-inline-size: 0;
margin: 0;
padding: 0;
border: 0;
}
.exportReport legend {
margin-block-end: var(--space-2);
padding: 0;
color: var(--fg-strong);
font-weight: 600;
}
.exportFormats {
display: grid;
justify-items: start;
gap: var(--space-1);
display: flex;
align-items: center;
gap: var(--space-4);
}
.exportOutput {
.exportField {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
grid-template-columns: auto minmax(0, 1fr);
align-items: center;
gap: var(--space-2);
}
.exportOutput > label {
max-inline-size: 120px;
overflow-wrap: anywhere;
color: var(--fg);
}
/* Folded console lines ("<N internal lines>"). */
.fold {
color: var(--fg-fold-placeholder);
+1 -2
View File
@@ -375,8 +375,7 @@ describe("Export Test Results", () => {
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
act(() => testTree.exportResults!());
expect(screen.getByRole("dialog", { name: "Export Test Results" })).toBeInTheDocument();
expect(screen.getByLabelText("File name")).toHaveValue("Test Results - calc tests.html");
expect(screen.getByLabelText("Folder")).toHaveValue("/p");
expect(screen.getByLabelText("Output file")).toHaveValue("/p/Test Results - calc tests.html");
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
expect(screen.queryByRole("dialog", { name: "Export Test Results" })).toBeNull();
unmount();
-1
View File
@@ -262,7 +262,6 @@ export function choiceItems(choices: readonly Produced[], debug: boolean): MenuI
{ kind: "header", label: debug ? "Choose configuration to debug" : "Choose configuration to run" },
...choices.map((p): MenuItem => ({
label: debug ? tx`Debug '${p.name}'` : tx`Run '${p.name}'`,
preserveLabelEnd: true,
verbatim: true,
icon: debug ? "debug" : "run",
shortcut: p.detail,
-2
View File
@@ -82,7 +82,6 @@ async function profileMenu(entry: ScriptEntry, path: string): Promise<MenuItem[]
return [
{
label: tx`Run '${config.name}'`,
preserveLabelEnd: true,
icon: "run",
shortcut: shortcutLabel("run.runContext"),
run: () =>
@@ -92,7 +91,6 @@ async function profileMenu(entry: ScriptEntry, path: string): Promise<MenuItem[]
},
{
label: tx`Debug '${config.name}'`,
preserveLabelEnd: true,
icon: "debug",
shortcut: shortcutLabel("run.debugContext"),
run: () => void executeAction("run.debugConfig", config),
-2
View File
@@ -283,7 +283,6 @@ export async function scriptMenuItems(entry: ScriptEntry, path: string, content:
return [
{
label: tx`Run '${label}'`,
preserveLabelEnd: true,
icon: "run",
shortcut: shortcutLabel("run.runContext"),
run: () =>
@@ -293,7 +292,6 @@ export async function scriptMenuItems(entry: ScriptEntry, path: string, content:
},
{
label: tx`Debug '${label}'`,
preserveLabelEnd: true,
icon: "debug",
shortcut: shortcutLabel("run.debugContext"),
run: () => void executeAction("run.debugConfig", config),
+1 -8
View File
@@ -109,18 +109,11 @@ export function targetMenuItems(target: RunTarget, path: string, content: string
: { run: () => void launch(target, path, debug, content) };
const debuggable = !p || canDebugProduced(p);
return [
{
label: tx`Run '${name}'`,
preserveLabelEnd: true,
icon: "run",
shortcut: shortcutLabel("run.runContext"),
...pick(false),
} as MenuItem,
{ label: tx`Run '${name}'`, icon: "run", shortcut: shortcutLabel("run.runContext"), ...pick(false) } as MenuItem,
...(debuggable
? [
{
label: tx`Debug '${name}'`,
preserveLabelEnd: true,
icon: "debug",
shortcut: shortcutLabel("run.debugContext"),
...pick(true),
@@ -103,9 +103,9 @@ describe("replace flow model", () => {
});
it("confirmation and summary texts carry the counts", () => {
expect(confirmText({ usages: 1, files: 1 })).toBe("Replace 1 occurrence in 1 file?");
expect(confirmText({ usages: 3, files: 1 })).toBe("Replace 3 occurrences in 1 file?");
expect(confirmText({ usages: 3, files: 2 })).toBe("Replace 3 occurrences in 2 files?");
expect(confirmText({ usages: 3, files: 1 }, "foo", "bar")).toBe(
"Replace 3 occurrences of 'foo' with 'bar' in 1 file?",
);
expect(summaryText({ files: 2, replacements: 1, failed: 0, cancelled: false, elapsedMs: 3 })).toBe(
"Replaced 1 occurrence in 2 files",
);
@@ -248,20 +248,6 @@
.rightActive {
color: var(--fg-muted);
}
.textLocation {
display: inline-flex;
align-items: baseline;
gap: var(--space-1);
}
.textFile {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.textLine {
flex: none;
font-variant-numeric: tabular-nums;
}
.actionRow {
flex: 1;
min-width: 0;
@@ -934,11 +934,8 @@ function ResultRow({
<span className={styles.main}>
<CodeText path={row.path} text={row.text} indices={row.indices} />
</span>
<span className={clsx(styles.right, styles.textLocation, active && styles.rightActive)}>
<span className={clsx(styles.textFile, repeat && !active && styles.repeat)} title={row.rel}>
{basename(row.rel)}
</span>{" "}
<span className={styles.textLine}>{row.line + 1}</span>
<span className={clsx(styles.right, active && styles.rightActive)}>
<span className={clsx(repeat && !active && styles.repeat)}>{basename(row.rel)}</span> {row.line + 1}
</span>
</>
);
@@ -201,32 +201,23 @@
.previewHeader {
flex: none;
display: flex;
align-items: baseline;
gap: var(--space-1);
padding: 10px 20px var(--space-1-5);
align-items: center;
justify-content: space-between;
gap: 10px;
height: 36px;
padding: 0 20px;
border-top: 1px solid var(--border-popup);
color: var(--fg-subtle);
font-size: var(--fs-ui);
line-height: 1.25;
white-space: nowrap;
}
.previewDirectory {
display: flex;
.previewPath {
min-width: 0;
}
.previewName,
.previewSegment {
min-width: 0;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.previewName,
.previewParent {
flex: none;
white-space: nowrap;
}
.previewName {
color: var(--fg-strong);
margin-right: 8px;
}
.previewBox {
flex: 1;
+48 -27
View File
@@ -1,4 +1,3 @@
import { SearchHistoryMenu } from "@/ui/SearchHistoryMenu";
import {
useEffect,
useId,
@@ -40,12 +39,14 @@ import {
} from "@/ui";
import { useRowHeight } from "@/ui/density";
import { maybeEditorService, notifications } from "@/workbench/contributions";
import { confirm } from "@/workbench/messages";
import { basename, dirname, openLocation } from "../common/open";
import { CodePreview, MatchText, ReplaceDiffPreview } from "./parts";
import { clearPreviewCache } from "./preview";
import { confirmReplacement } from "./ReplaceAllConfirmation";
import {
NO_MARKS,
confirmAllText,
confirmText,
countUsages,
groupState,
loadReplacePreview,
@@ -73,6 +74,7 @@ import {
customScopeName,
customScopeValue,
describeQuery,
findHistory,
hideFindPopup,
recentMasks,
rememberFindString,
@@ -282,8 +284,6 @@ function FindInFilesDialog() {
const rows = useMemo(() => matchRows(state.files), [state.files]);
const active = rows.length ? Math.min(sel.lead, rows.length - 1) : -1;
const selected = active >= 0 ? rows[active] : undefined;
const previewDirectory = selected?.relPath.includes("/") ? dirname(selected.relPath) : "";
const previewParentStart = Math.max(0, previewDirectory.lastIndexOf("/"));
const chosen = useMemo(() => selectedRows(rows, sel), [rows, sel]);
const fileHighlights = useMemo(() => {
if (stale || !selected) return [];
@@ -346,11 +346,22 @@ function FindInFilesDialog() {
void replaceAll(usages);
return;
}
const ok = await confirmReplacement({
counts: allInScope ? null : counts,
pattern: s.pattern,
replacement: s.replacement || "",
hasExclusions: marks.excluded.size > 0,
const ok = await confirm({
title: "Replace All",
ok: "Replace",
message: (
<>
{allInScope
? confirmAllText(s.pattern, s.replacement || "")
: confirmText(counts, s.pattern, s.replacement || "")}
{marks.excluded.size > 0 && (
<>
{" "}
<T>Excluded usages are skipped.</T>
</>
)}
</>
),
});
if (ok) void replaceAll(usages, allInScope);
};
@@ -552,6 +563,19 @@ function FindInFilesDialog() {
checked: m === s.mask ? true : undefined,
run: () => set({ mask: m, maskEnabled: true }),
}));
const historyItems = (kind: "find" | "replace"): MenuItem[] => {
const h = findHistory(kind);
return h.length
? [
{ kind: "header", label: kind === "find" ? "Recent Searches" : "Recent Replacements" },
...h.map((q) => ({
label: q,
verbatim: true,
run: () => set(kind === "find" ? { pattern: q } : { replacement: q }),
})),
]
: [{ label: kind === "find" ? "No recent searches" : "No recent replacements", disabled: true }];
};
const contextItems: MenuItem[] = SEARCH_CONTEXTS.map((c) => ({
label: c.label,
checked: c.value === s.context ? true : undefined,
@@ -866,21 +890,16 @@ function FindInFilesDialog() {
</SplitPanel>
<SplitHandle hairline={false} />
<SplitPanel id="preview" minSize={96}>
{selected && (
<div className={styles.previewHeader} title={selected.relPath}>
<span className={styles.previewName}>{basename(selected.relPath)}</span>
{previewDirectory && (
<span className={styles.previewDirectory} dir="ltr">
{previewParentStart > 0 && (
<span className={styles.previewSegment}>{previewDirectory.slice(0, previewParentStart)}</span>
)}
<span className={clsx(styles.previewSegment, styles.previewParent)}>
{previewDirectory.slice(previewParentStart)}
</span>
</span>
)}
</div>
)}
<div className={styles.previewHeader}>
{selected ? (
<span className={styles.previewPath}>
<span className={styles.previewName}>{basename(selected.relPath)}</span>
{selected.relPath.includes("/") && dirname(selected.relPath)}
</span>
) : (
<span />
)}
</div>
<div className={styles.previewBox}>
{!stale && previewMode && s.replace && selected ? (
<ReplaceDiffPreview
@@ -955,10 +974,12 @@ function FindInFilesDialog() {
placement="bottom-end"
onClose={() => setMaskMenu(false)}
/>
<SearchHistoryMenu
kind={historyMenu}
<Menu
open={historyMenu !== null}
anchor={historyMenu === "replace" ? replaceBoxRef : patternBoxRef}
onSelect={(value) => set(historyMenu === "replace" ? { replacement: value } : { pattern: value })}
items={historyMenu ? historyItems(historyMenu) : []}
placement="bottom-start"
aria-label="Recent searches"
onClose={() => setHistoryMenu(null)}
/>
<Menu
+19 -6
View File
@@ -23,12 +23,14 @@ import {
T,
} from "@/ui";
import { notifications, useOccurrenceNavigator } from "@/workbench/contributions";
import { confirm } from "@/workbench/messages";
import { basename, openLocation, relDir } from "../common/open";
import { countFileMatches } from "./session";
import { CodePreview, MatchText, type PreviewHighlight } from "./parts";
import { confirmReplacement } from "./ReplaceAllConfirmation";
import {
NO_MARKS,
confirmAllText,
confirmText,
countUsages,
groupState,
loadReplacePreview,
@@ -367,11 +369,22 @@ function FindTabView({ tab }: { tab: FindTab }) {
// Past the search's limit, every match in the scope is replaced, listed or not (as in IDEA).
const allInScope = !!st.summary?.limitHit;
const confirmReplaceAll = async () => {
const ok = await confirmReplacement({
counts: allInScope ? null : countUsages(allPending),
pattern: tab.query.pattern,
replacement: tab.replacement ?? "",
hasExclusions: marks.excluded.size > 0,
const ok = await confirm({
title: "Replace All",
ok: "Replace",
message: (
<>
{allInScope
? confirmAllText(tab.query.pattern, tab.replacement ?? "")
: confirmText(countUsages(allPending), tab.query.pattern, tab.replacement ?? "")}
{marks.excluded.size > 0 && (
<>
{" "}
<T>Excluded usages are skipped.</T>
</>
)}
</>
),
});
if (ok) void replace(allPending, allInScope);
};
@@ -1,51 +0,0 @@
.content {
display: grid;
gap: var(--space-2);
font-size: var(--fs-ui);
}
.content p,
.values,
.values dd,
.values pre {
margin: 0;
}
.values {
display: grid;
grid-template-columns: auto minmax(0, 1fr);
align-items: start;
gap: var(--space-2);
}
.values dt {
padding-block: var(--space-1);
color: var(--fg-secondary);
}
.values pre {
max-height: 5em;
padding: var(--space-1) var(--space-2);
overflow: auto;
border: 1px solid var(--border);
border-radius: var(--radius-control);
background: var(--bg-field);
font-family: var(--font-mono);
font-size: inherit;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.values pre:focus-visible {
outline: 1px solid var(--focus-ring);
}
.empty {
color: var(--fg-muted);
font-family: var(--font-ui);
}
.note {
color: var(--fg-muted);
font-size: var(--fs-small);
}
@@ -1,59 +0,0 @@
import { tx } from "@/platform/i18n";
import { T } from "@/ui";
import { confirm } from "@/workbench/messages";
import { confirmText, type ReplaceCounts } from "./replaceFlow";
import styles from "./ReplaceAllConfirmation.module.css";
export function confirmReplacement({
counts,
pattern,
replacement,
hasExclusions,
}: {
counts: ReplaceCounts | null;
pattern: string;
replacement: string;
hasExclusions: boolean;
}): Promise<boolean> {
return confirm({
title: "Replace All",
ok: "Replace",
message: (
<div className={styles.content}>
<p>{counts ? confirmText(counts) : <T>Replace every occurrence in the scope?</T>}</p>
<dl className={styles.values}>
<dt>
<T>Text to find</T>
</dt>
<dd>
<pre role="region" aria-label={tx("Text to find")} tabIndex={0}>
{pattern}
</pre>
</dd>
<dt>
<T>Replace with</T>
</dt>
<dd>
<pre role="region" aria-label={tx("Replace with")} tabIndex={0}>
{replacement || (
<span className={styles.empty}>
<T>Empty text</T>
</span>
)}
</pre>
</dd>
</dl>
{!counts && (
<p className={styles.note}>
<T>The search hit its limit, so it runs again to find any additional matches.</T>
</p>
)}
{hasExclusions && (
<p className={styles.note}>
<T>Excluded usages are skipped.</T>
</p>
)}
</div>
),
});
}
@@ -1,32 +1,26 @@
.body {
display: grid;
grid-template-columns: 200px minmax(0, 1fr);
grid-template-rows: minmax(0, 1fr);
height: clamp(240px, 55vh, 360px);
grid-template-columns: 200px 1fr;
min-height: 300px;
border: 1px solid var(--border);
border-radius: var(--radius-small);
overflow: hidden;
}
.side {
display: flex;
flex-direction: column;
min-width: 0;
min-height: 0;
border-inline-end: 1px solid var(--border);
border-right: 1px solid var(--border);
}
.toolbar {
display: flex;
flex: none;
gap: var(--space-0-5);
padding: var(--space-1);
padding: 4px;
border-bottom: 1px solid var(--border);
}
.list {
flex: 1;
min-height: 0;
margin: 0;
padding: var(--space-1);
scroll-padding-block: var(--space-1);
padding: 4px;
list-style: none;
overflow: auto;
}
@@ -35,16 +29,13 @@
align-items: center;
width: 100%;
height: var(--h-list-row);
padding: 0 var(--space-2);
padding: 0 8px;
border: 0;
border-radius: var(--radius-row);
background: none;
color: var(--fg);
font-size: var(--fs-ui);
text-align: start;
}
.item > span {
min-width: 0;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -56,25 +47,16 @@
background: var(--bg-list-selected);
}
.empty {
padding: var(--space-2);
padding: 8px;
color: var(--fg-muted);
font-size: var(--fs-ui);
}
.form {
display: grid;
grid-template-columns: max-content minmax(0, 1fr);
align-items: center;
align-content: start;
gap: var(--space-2) var(--space-3);
padding: var(--space-3);
display: flex;
flex-direction: column;
gap: var(--space-1-5);
padding: 10px 14px;
min-width: 0;
min-height: 0;
overflow: auto;
}
.form > .error,
.form > .empty,
.help {
grid-column: 1 / -1;
}
.label {
color: var(--fg-muted);
@@ -83,11 +65,10 @@
.error {
color: var(--danger);
font-size: var(--fs-small);
overflow-wrap: anywhere;
}
.help {
margin: 0;
padding-inline-start: var(--space-4);
margin: 6px 0 0;
padding-left: 16px;
color: var(--fg-muted);
font-size: var(--fs-small);
line-height: 1.6;
@@ -96,15 +77,3 @@
font-family: var(--font-mono);
color: var(--fg);
}
@media (max-width: 540px) {
.body {
grid-template-columns: minmax(0, 1fr);
grid-template-rows: minmax(84px, 1fr) minmax(0, auto);
height: clamp(240px, 65vh, 360px);
}
.side {
border-inline-end: 0;
border-bottom: 1px solid var(--border);
}
}
+3 -9
View File
@@ -3,7 +3,7 @@
* file pattern, saved per project (`@/platform/search`) and offered wherever
* named scopes are (Find in Files, the analyses' Specify Scope).
*/
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { useEffect, useId, useState } from "react";
import clsx from "clsx";
import { create } from "zustand";
import { tx, txTemplate, useTx, useTxTemplate } from "@/platform/i18n";
@@ -88,10 +88,6 @@ function ScopesDialog() {
const select = useScopesDialog.getState().select;
return Math.max(0, select ? scopes.findIndex((s) => s.name === select) : 0);
});
const selectedRow = useRef<HTMLButtonElement>(null);
useLayoutEffect(() => {
selectedRow.current?.scrollIntoView({ block: "nearest" });
}, [index, scopes.length]);
const current = scopes[index] ?? null;
const patternError = usePatternError(current?.pattern ?? "");
const problem = scopesProblem(scopes);
@@ -128,7 +124,7 @@ function ScopesDialog() {
>
<div className={styles.body}>
<div className={styles.side}>
<div className={styles.toolbar} role="toolbar" aria-label={tr("Scopes actions")}>
<div className={styles.toolbar}>
<IconButton icon="plus" title="Add Scope" size="small" onClick={add} />
<IconButton icon="minus" title="Remove Scope" size="small" disabled={!current} onClick={remove} />
</div>
@@ -138,13 +134,11 @@ function ScopesDialog() {
<li key={i}>
<button
type="button"
ref={i === index ? selectedRow : undefined}
className={clsx(styles.item, i === index && styles.itemOn)}
aria-current={i === index || undefined}
title={s.name}
onClick={() => setIndex(i)}
>
<span>{s.name || tr("Unnamed")}</span>
{s.name || tr("Unnamed")}
</button>
</li>
))}
+9 -4
View File
@@ -91,10 +91,15 @@ export function countUsages(usages: readonly Usage[]): ReplaceCounts {
}
/** "Replace 3 occurrences in 2 files" for the confirmation dialog. */
export function confirmText({ usages, files }: ReplaceCounts): string {
if (usages === 1) return tx("Replace 1 occurrence in 1 file?");
if (files === 1) return tx`Replace ${usages} occurrences in 1 file?`;
return tx`Replace ${usages} occurrences in ${files} files?`;
export function confirmText(c: ReplaceCounts, pattern: string, replacement: string): string {
const occ = `${c.usages} occurrence${c.usages === 1 ? "" : "s"}`;
const files = `${c.files} file${c.files === 1 ? "" : "s"}`;
return `Replace ${occ} of '${pattern}' with '${replacement}' in ${files}?`;
}
/** Confirmation for Replace All once the search hit its limit (the count shown is not the total). */
export function confirmAllText(pattern: string, replacement: string): string {
return tx`Replace every occurrence of '${pattern}' with '${replacement}' in the scope? The search hit its limit, so it runs again to find the occurrences not listed.`;
}
/** Toggles exclusion of every usage in `groups` (all excluded → include them again). */
@@ -42,14 +42,6 @@
margin-inline: 0;
border-radius: 0;
}
.tree [data-tree-toggle] {
margin-inline-start: var(--space-2);
width: var(--space-3);
}
.tree [data-tree-toggle] svg {
width: var(--space-3);
height: var(--space-3);
}
.tree [role="treeitem"][aria-selected="true"] {
background: var(--bg-tree-selected);
}
@@ -360,7 +360,6 @@ export function SettingsLayout() {
isExpandable={(n) => n.children.length > 0}
defaultExpanded={current ? ancestorKeys(tree, current.key) : []}
expanded={query ? expanded : undefined}
indent={16}
selected={current ? new Set([current.key]) : new Set()}
onSelectionChange={(_sel, node) => node && selectPage(node.key)}
multiSelect={false}
+24 -56
View File
@@ -30,6 +30,9 @@
.presetSelect {
flex: 1;
}
.spacer {
flex: 1;
}
.modifiedNote {
color: var(--fg-subtle);
font-size: var(--fs-small);
@@ -192,88 +195,53 @@
.recordLabel {
color: var(--fg);
}
.shortcutBody {
display: flex;
flex-direction: column;
gap: var(--space-2);
padding: var(--space-2) var(--space-3) 0;
font-size: var(--fs-ui);
overflow-wrap: anywhere;
}
.actionSummary {
display: grid;
gap: var(--space-0-5);
}
.actionName {
color: var(--fg-strong);
font-weight: 600;
}
.shortcutField {
flex: 0 0 auto;
background: var(--bg-field);
}
.shortcutField > span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.secondStroke {
display: flex;
align-items: center;
gap: var(--space-2);
}
.secondStroke > label {
max-width: 55%;
}
.secondStroke .shortcutField {
flex: 1;
}
.recordHint {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.shortcutStatus {
display: grid;
gap: var(--space-1);
.conflicts {
min-height: 72px;
padding: 6px 8px;
border-radius: var(--radius-small);
box-shadow: inset 0 0 0 1px var(--border);
}
.noConflicts {
color: var(--fg-subtle);
}
.conflictTitle {
display: flex;
align-items: center;
gap: var(--space-1-5);
color: var(--fg-emphasis);
font-weight: 600;
}
.conflictIcon {
flex: none;
color: var(--warning);
--icon-color: currentColor;
}
.conflictList {
list-style: none;
margin: 0;
padding: 0;
max-height: 132px;
overflow-y: auto;
margin: 6px 0 0;
padding: 0 0 0 20px;
max-height: 120px;
overflow: auto;
}
.conflictList li {
display: grid;
grid-template-columns: minmax(0, 1fr) fit-content(42%);
align-items: start;
display: flex;
min-width: 0;
align-items: center;
gap: var(--space-2);
padding-block: var(--space-1);
height: var(--h-row);
}
.conflictAction {
color: var(--fg);
overflow-wrap: anywhere;
}
.actionPath {
.conflictCategory {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.conflictBinding {
text-align: end;
white-space: normal;
overflow-wrap: anywhere;
.conflictsLabel {
color: var(--fg);
padding-top: 4px;
}
.nameError {
color: var(--danger);
@@ -20,7 +20,7 @@ import { findConflicts, resolveBindings, type Conflict, type KeymapDraft } from
import { groupPath } from "./groups";
import { StrokeRecorder } from "./StrokeRecorder";
import styles from "./Keymap.module.css";
import { useTx } from "@/platform/i18n";
import { tx } from "@/platform/i18n";
import { usePlatform } from "@/platform/platformInfo";
export interface RecordShortcutDialogProps {
@@ -39,8 +39,6 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
const [second, setSecond] = useState("");
const [useSecond, setUseSecond] = useState(false);
const os = usePlatform((s) => s.os);
const tx = useTx();
const actionName = tx(action.title);
const rectangularSelection = action.id === "editor.createRectangularSelectionOnMouseDrag";
const allowsSecond = !isPageSwipe(first) && !parseDoubleModifier(first);
@@ -78,23 +76,14 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
<Dialog
open
onClose={onCancel}
title={mouse ? "Mouse Shortcut" : "Keyboard Shortcut"}
aria-label={mouse ? tx`Mouse Shortcut: ${actionName}` : tx`Keyboard Shortcut: ${actionName}`}
width={352}
title={mouse ? tx`Mouse Shortcut: ${action.title}` : tx`Keyboard Shortcut: ${action.title}`}
width={440}
buttons={[
{ label: "OK", role: "default", disabled: !binding || already, onClick: () => void ok() },
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.shortcutBody}>
<div className={styles.actionSummary}>
<div className={styles.actionName}>{actionName}</div>
<div className={styles.actionPath}>
{groupPath(action)
.map((part) => tx(part))
.join(" › ")}
</div>
</div>
<div className={styles.recordBody}>
{mouse ? (
<MouseRecorder value={first} onChange={setFirst} sideButtons={!rectangularSelection} />
) : (
@@ -113,23 +102,31 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
<T>On Linux, middle-button rectangular selection conflicts with primary selection paste.</T>
</div>
)}
<div className={styles.shortcutStatus} aria-live="polite">
<div className={styles.conflictsLabel}>
<T>Conflicts:</T>
</div>
<div className={styles.conflicts} aria-live="polite">
{already && (
<span className={styles.recordHint}>
<span className={styles.noConflicts}>
<T>The action already has this shortcut</T>
</span>
)}
{!already && binding && conflicts.length === 0 && (
<span className={styles.recordHint}>
<span className={styles.noConflicts}>
<T>No conflicts</T>
</span>
)}
{!binding && (
<span className={styles.noConflicts}>
<T>Press a shortcut</T>
</span>
)}
{conflicts.length > 0 && (
<>
<div className={styles.conflictTitle}>
<Icon name="warning" size={14} className={styles.conflictIcon} />
<span>
<Kbd binding={binding} className={styles.conflictBinding} /> <T>is already assigned to:</T>
<Kbd binding={binding} /> <T>is already assigned to:</T>
</span>
</div>
<ConflictList conflicts={conflicts} />
@@ -142,26 +139,21 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
}
function ConflictList({ conflicts }: { conflicts: readonly Conflict[] }) {
const tx = useTx();
return (
<ul className={styles.conflictList} aria-label={tx("Conflicts:")}>
<ul className={styles.conflictList}>
{conflicts.map((c) => (
<li key={`${c.actionId}|${c.binding}`}>
<div className={styles.conflictAction}>
<div>{tx(c.title)}</div>
<span className={styles.actionPath}>
{groupPath({ id: c.actionId, category: c.category })
.map((part) => tx(part))
.join(" › ")}
{c.kind === "prefix" && (
<>
{" "}
· <T>chord prefix</T>
</>
)}
<span className={styles.conflictAction}>{c.title}</span>
<span className={styles.conflictCategory}>
({groupPath({ id: c.actionId, category: c.category }).join(" | ")})
</span>
<span className={styles.spacer} />
{c.kind === "prefix" && (
<span className={styles.conflictCategory}>
<T>chord prefix</T>
</span>
</div>
<Kbd binding={c.binding} className={styles.conflictBinding} />
)}
<Kbd binding={c.binding} />
</li>
))}
</ul>
@@ -179,26 +171,23 @@ interface KeyStrokesProps {
}
function KeyStrokes({ first, second, useSecond, allowsSecond, setFirst, setSecond, setUseSecond }: KeyStrokesProps) {
const tx = useTx();
return (
<>
<StrokeRecorder
autoFocus
className={styles.shortcutField}
value={first}
onChange={setFirst}
aria-label={tx("First stroke")}
/>
<div className={styles.secondStroke}>
<div className={styles.recordRow}>
<span className={styles.recordLabel}>
<T>First stroke:</T>
</span>
<StrokeRecorder autoFocus value={first} onChange={setFirst} aria-label="First stroke" />
</div>
<div className={styles.recordRow}>
<Checkbox checked={useSecond} onChange={setUseSecond} disabled={!allowsSecond} label="Second stroke:" />
<StrokeRecorder
className={styles.shortcutField}
value={second}
onChange={setSecond}
disabled={!useSecond}
allowDoubleModifier={false}
placeholder={useSecond ? "Press a shortcut" : ""}
aria-label={tx("Second stroke")}
aria-label="Second stroke"
/>
</div>
<div className={styles.recordHint}>
+46 -57
View File
@@ -166,64 +166,53 @@ export function TerminalFindBar({ sessionKey }: { sessionKey: string | null }) {
placeholder="Find in terminal"
aria-label="Find in terminal"
invalid={none}
toggles={[
{
id: "case",
icon: "case",
title: "Match Case",
shortcut: formatBinding("Alt+C"),
pressed: options.caseSensitive,
onToggle: () => toggle("caseSensitive"),
},
{
id: "word",
icon: "word",
title: "Words",
shortcut: formatBinding("Alt+W"),
pressed: options.wholeWord,
onToggle: () => toggle("wholeWord"),
},
{
id: "regex",
icon: "regex",
title: "Regex",
shortcut: formatBinding("Alt+X"),
pressed: options.regex,
onToggle: () => toggle("regex"),
},
]}
/>
<div className={styles.findControls}>
<div className={styles.findOptions}>
<IconButton
icon="case"
title="Match Case"
shortcut={formatBinding("Alt+C")}
pressed={options.caseSensitive}
size="small"
onClick={() => toggle("caseSensitive")}
/>
<IconButton
icon="word"
title="Words"
shortcut={formatBinding("Alt+W")}
pressed={options.wholeWord}
size="small"
onClick={() => toggle("wholeWord")}
/>
<IconButton
icon="regex"
title="Regex"
shortcut={formatBinding("Alt+X")}
pressed={options.regex}
size="small"
onClick={() => toggle("regex")}
/>
</div>
<div className={styles.findActions}>
<span className={clsx(styles.findCount, none && styles.findCountNone)} aria-live="polite">
{counter}
</span>
<IconButton
icon="arrow-up"
title="Previous Occurrence"
shortcut={formatBinding("Shift+Enter")}
size="small"
disabled={!query || !result?.count}
onClick={() => find("previous")}
/>
<IconButton
icon="arrow-down"
title="Next Occurrence"
shortcut="↵"
size="small"
disabled={!query || !result?.count}
onClick={() => find("next")}
/>
</div>
<IconButton
className={styles.findClose}
icon="close"
title="Close"
shortcut="⎋"
size="small"
onClick={closeTerminalFind}
/>
</div>
<span className={clsx(styles.findCount, none && styles.findCountNone)} aria-live="polite">
{counter}
</span>
<IconButton
icon="arrow-up"
title="Previous Occurrence"
shortcut={formatBinding("Shift+Enter")}
size="small"
disabled={!query || !result?.count}
onClick={() => find("previous")}
/>
<IconButton
icon="arrow-down"
title="Next Occurrence"
shortcut="↵"
size="small"
disabled={!query || !result?.count}
onClick={() => find("next")}
/>
<IconButton icon="close" title="Close" shortcut="⎋" size="small" onClick={closeTerminalFind} />
</div>
);
}
+11 -29
View File
@@ -163,33 +163,21 @@
display: flex;
align-items: center;
gap: var(--space-1);
padding: var(--space-1) var(--space-2);
padding: 4px 8px;
background: var(--bg-elev);
border-bottom: 1px solid var(--border);
font-size: var(--fs-ui);
}
.findField {
width: calc(14ch + 2 * var(--h-control-small) + var(--space-4));
min-width: 0;
}
.findControls,
.findOptions,
.findActions {
display: flex;
align-items: center;
gap: var(--space-0-5);
}
.findControls {
gap: var(--space-1);
flex: 1;
min-width: 160px;
}
.findCount {
font-size: var(--fs-ui);
font-size: var(--fs-small);
font-variant-numeric: tabular-nums;
color: var(--fg-subtle);
min-inline-size: 7ch;
padding-inline: var(--space-1);
text-align: center;
padding: 0 6px;
white-space: nowrap;
min-width: 56px;
}
.findCountNone {
color: var(--danger);
@@ -200,8 +188,7 @@
top: 0;
right: 0;
z-index: 6;
width: max-content;
max-width: 100%;
width: 500px;
border-left: 1px solid var(--border);
}
.find[data-match-covered] {
@@ -214,16 +201,11 @@
@container terminal-output (max-width: 360px) {
.find {
flex-direction: column;
align-items: stretch;
display: grid;
grid-template-columns: minmax(0, 1fr) repeat(3, var(--h-control-small));
}
.findField {
width: 100%;
}
.findControls {
flex-wrap: wrap;
}
.findClose {
margin-inline-start: auto;
grid-column: 1 / -1;
min-width: 0;
}
}
-1
View File
@@ -42,7 +42,6 @@ export function AmendTargetMenu({ root }: { root: string }) {
{
value: LAST_COMMIT,
label: "Amend Last Commit",
emphasized: true,
detail: available?.latest?.summary,
verbatimDetail: true,
},
+9 -12
View File
@@ -1,31 +1,26 @@
.popup {
width: max-content;
width: min(540px, calc(100vw - 32px));
max-height: min(480px, 65vh);
overflow: auto;
padding: 12px 14px;
white-space: normal;
overflow-wrap: anywhere;
-webkit-user-select: text;
user-select: text;
font-family: var(--font-ui);
font-size: var(--fs-ui);
line-height: 1.5;
}
.content {
max-inline-size: min(540px, 80vw);
padding: 10px var(--space-3);
}
.header {
color: var(--fg);
line-height: 1.45;
}
.hashLink {
max-inline-size: 100%;
color: var(--link);
font: inherit;
font-family: var(--font-mono);
font-size: inherit;
cursor: pointer;
word-break: break-all;
text-align: left;
}
@@ -35,14 +30,16 @@
}
.subject {
margin-block-start: var(--space-3);
margin-top: 10px;
color: var(--fg-strong);
font-weight: 600;
white-space: pre-wrap;
word-break: break-word;
}
.body {
margin-block-start: var(--space-2);
margin-top: 8px;
color: var(--fg);
white-space: pre-wrap;
word-break: break-word;
}
+1 -5
View File
@@ -147,11 +147,7 @@ function BlamePopupView({ state }: { state: BlamePopupState }) {
onClose={() => closeBlamePopup()}
className={styles.popup}
>
<div
className={styles.content}
onPointerEnter={cancelBlamePopupTimers}
onPointerLeave={() => scheduleCloseBlamePopup()}
>
<div onPointerEnter={cancelBlamePopupTimers} onPointerLeave={() => scheduleCloseBlamePopup()}>
<div className={styles.header}>
<div>
commit{" "}
+7 -7
View File
@@ -33,17 +33,15 @@ export function CommitAuthorFields({
focusAuthor?: boolean;
onChange: (update: Partial<CommitAuthor>) => void;
}) {
const authorId = useId();
const authorDateId = useId();
const date = authorDate ? new Date(authorDate) : null;
return (
<div className={styles.optIdentity}>
<div className={styles.optIdentityFields}>
<label htmlFor={authorId}>
<>
<label className={styles.optField}>
<span>
<T>Author:</T>
</label>
</span>
<Input
id={authorId}
value={author}
title={tx(
preserveOriginal
@@ -55,6 +53,8 @@ export function CommitAuthorFields({
autoSelect={focusAuthor}
onChange={(e) => onChange({ author: e.target.value })}
/>
</label>
<div className={styles.optDate}>
<label htmlFor={authorDateId}>
<T>Author date</T>
</label>
@@ -81,6 +81,6 @@ export function CommitAuthorFields({
)}
</div>
</div>
</div>
</>
);
}
-65
View File
@@ -1,65 +0,0 @@
.search {
display: flex;
padding: var(--space-2) var(--space-3);
}
.search > * {
flex: 1;
min-width: 0;
}
.results {
display: flex;
flex-direction: column;
max-height: max(84px, calc(100vh - 144px));
margin-bottom: var(--space-2);
}
.list {
flex: 1;
}
.choice {
display: flex;
flex-direction: column;
width: 100%;
min-width: 0;
}
.choice > span {
pointer-events: none;
}
.subject,
.author,
.date {
overflow: hidden;
text-overflow: ellipsis;
}
.subject {
font-size: var(--fs-ui);
}
.metadata {
display: flex;
gap: var(--space-2);
align-items: baseline;
color: var(--fg-muted);
font-size: var(--fs-small);
}
.hash {
flex: none;
font-family: var(--font-mono);
}
.author {
flex: 1;
min-width: 0;
}
.date {
flex: none;
max-width: 50%;
}
+11 -70
View File
@@ -1,14 +1,9 @@
import { useId, useState, type KeyboardEvent } from "react";
import { useState } from "react";
import type { Commit } from "@/bindings";
import { tx } from "@/platform/i18n";
import { Dialog, List, SearchField, T, listNavigate } from "@/ui";
import { Dialog, List, SearchField } from "@/ui";
import { openDialog } from "./dialogs";
import { formatTime } from "./model";
import { commitKey } from "./multiRoot";
import styles from "./CommitChooser.module.css";
const ROW_HEIGHT = 42;
const VISIBLE_ROWS = 8;
import { useRowHeight } from "@/ui/density";
export function chooseLogCommit(commits: Commit[], title: string): Promise<Commit | null> {
return new Promise((resolve) => {
@@ -34,76 +29,22 @@ function CommitChooser({
title: string;
onDone: (commit: Commit | null) => void;
}) {
const listId = useId();
const rowHeight = useRowHeight(26);
const [query, setQuery] = useState("");
const [active, setActive] = useState(0);
const filter = query.toLocaleLowerCase();
const shown = commits.filter((commit) =>
`${commit.id} ${commit.summary} ${commit.author}`.toLocaleLowerCase().includes(filter),
const shown = commits.filter((c) =>
`${c.id} ${c.summary} ${c.author}`.toLocaleLowerCase().includes(query.toLocaleLowerCase()),
);
const selected = Math.min(active, shown.length - 1);
const onKeyDown = (event: KeyboardEvent) => {
if (event.nativeEvent.isComposing) return;
if (event.key === "Enter") {
event.preventDefault();
if (shown[selected]) onDone(shown[selected]);
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
const next = listNavigate(event.key, { items: shown, active: selected, wrap: true });
if (next === null) return;
event.preventDefault();
setActive(next);
}
};
return (
<Dialog open title={title} onClose={() => onDone(null)} width={520}>
<div className={styles.search}>
<SearchField
data-autofocus
role="combobox"
aria-expanded
aria-controls={listId}
aria-autocomplete="list"
aria-activedescendant={selected >= 0 ? `${listId}-${selected}` : undefined}
value={query}
onChange={(value) => {
setQuery(value);
setActive(0);
}}
onKeyDown={onKeyDown}
placeholder="Search commits"
aria-label="Search commits"
/>
</div>
<div
className={styles.results}
style={{ height: Math.max(1, Math.min(commits.length, VISIBLE_ROWS)) * ROW_HEIGHT }}
>
<SearchField value={query} onChange={setQuery} placeholder="Search commits" aria-label="Search commits" />
<div style={{ height: 260, display: "flex" }}>
<List
id={listId}
items={shown}
getKey={commitKey}
activeIndex={selected}
onActiveChange={setActive}
renderItem={(c) => `${c.shortId} ${c.summary} — ${c.author}`}
onActivate={onDone}
focusable={false}
rowHeight={ROW_HEIGHT}
aria-label={tx(title)}
empty={<T>No commits</T>}
className={styles.list}
renderItem={(commit) => {
const date = formatTime(commit.timeMs);
return (
<span className={styles.choice} title={[commit.summary, commit.shortId, commit.author, date].join("\n")}>
<span className={styles.subject}>{commit.summary}</span>
<span className={styles.metadata}>
<span className={styles.hash}>{commit.shortId}</span>
<span className={styles.author}>{commit.author}</span>
{date && <span className={styles.date}>{date}</span>}
</span>
</span>
);
}}
rowHeight={rowHeight}
aria-label={title}
/>
</div>
</Dialog>
+16 -44
View File
@@ -89,9 +89,6 @@
.groupLabel {
color: var(--fg-strong);
}
.stageGroupLabel {
font-weight: 600;
}
.detail {
flex: 0 10000 auto;
min-width: 0;
@@ -137,22 +134,6 @@
gap: var(--space-0-5) var(--space-1);
padding: var(--space-0-5) 6px var(--space-0-5) 12px;
}
.messageHistory {
--history-row-height: max(var(--h-list-row), calc(1em + var(--space-2)));
min-width: min(180px, calc(100vw - var(--space-3)));
max-height: calc(7 * var(--history-row-height) + var(--space-2) + 2px);
padding-block: var(--space-1);
overflow-x: hidden;
}
.messageHistory [role="menu"] {
max-width: calc(var(--history-columns) + var(--space-4) + var(--space-2));
font-size: inherit;
}
.messageHistory [role="menuitem"] {
height: var(--history-row-height);
margin-inline: var(--space-1);
padding-inline: var(--space-2);
}
.amendTarget {
min-width: 0;
max-width: 112px;
@@ -162,13 +143,9 @@
text-overflow: ellipsis;
}
.amendPicker {
width: max-content;
min-width: min(280px, calc(100vw - var(--space-4)));
width: min(360px, calc(100vw - var(--space-4)));
padding-block: var(--space-1);
}
.amendPicker > * {
max-width: 520px;
}
.amendPickerRows {
max-height: calc(5 * var(--h-list-row));
}
@@ -332,7 +309,7 @@
}
/* Commit Options popup (gear next to Commit). */
.options {
width: 384px;
width: 340px;
max-height: min(560px, 80vh);
overflow: auto;
padding: 4px 16px 12px;
@@ -373,35 +350,29 @@
flex: 1;
min-width: 0;
}
.optIdentity {
container-type: inline-size;
}
.optIdentityFields {
display: grid;
grid-template-columns: minmax(0, 1fr);
.optField {
display: flex;
align-items: center;
gap: var(--space-1) var(--space-2);
gap: var(--space-2);
color: var(--fg);
font-size: var(--fs-ui);
}
.optIdentityFields > label {
overflow-wrap: anywhere;
.optField > :last-child {
flex: 1;
min-width: 0;
}
@container (min-width: 328px) {
.optIdentityFields {
grid-template-columns: fit-content(32%) minmax(0, 1fr);
row-gap: var(--space-1-5);
}
.optDate {
display: flex;
flex-direction: column;
gap: var(--space-1);
color: var(--fg);
}
.optDateInput {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: flex-end;
gap: var(--space-1);
}
.optDateInput input {
flex: 1 1 min(100%, 212px);
flex: 1;
min-width: 0;
}
.optLink {
@@ -491,13 +462,14 @@
.checkProblemLink:hover {
text-decoration: underline;
}
/* Staging area: Stage / Unstage on the hovered or selected row, as a hover icon at the row's end. */
.stageButton {
flex: none;
margin-left: auto;
visibility: hidden;
}
[role="treeitem"]:hover .stageButton,
.stageButtonLead {
[role="treeitem"][aria-selected="true"] .stageButton {
visibility: visible;
}
.inspectionFix {
+22 -36
View File
@@ -29,8 +29,7 @@ import {
EmptyState,
Icon,
IconButton,
MenuList,
Popup,
Menu,
Spinner,
SplitGroup,
SplitHandle,
@@ -591,7 +590,7 @@ export function stageOperation(n: ChangeNode): { label: string; icon: "plus" | "
return null;
}
function StageButton({ node, leadSelected }: { node: ChangeNode; leadSelected: boolean }) {
function StageButton({ node }: { node: ChangeNode }) {
const op = stageOperation(node);
if (!op) return null;
const { label, icon, paths } = op;
@@ -601,7 +600,7 @@ function StageButton({ node, leadSelected }: { node: ChangeNode; leadSelected: b
icon={icon}
title={label}
size="small"
className={clsx(styles.stageButton, leadSelected && styles.stageButtonLead)}
className={styles.stageButton}
onMouseDown={(e) => e.stopPropagation()}
onDoubleClick={(e) => e.stopPropagation()}
onClick={(e) => {
@@ -1162,7 +1161,6 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
className={clsx(
styles.label,
n.type === "group" && styles.groupLabel,
staging && n.type === "group" && styles.stageGroupLabel,
n.type === "group" && n.changelist && !n.active && styles.inactiveList,
)}
style={n.type === "file" && n.kind ? { color: KIND_COLOR[n.kind] } : undefined}
@@ -1270,7 +1268,7 @@ export function ChangesTree({ mode, amended }: { mode: "commit" | "local" | "dia
)}
{n.detail && n.detailIcon && <Icon name={n.detailIcon} size={14} className={styles.detailIcon} />}
{n.detail && <span className={styles.detail}>{n.detail}</span>}
{staging && <StageButton node={n} leadSelected={st.selected && st.lead} />}
{staging && <StageButton node={n} />}
</span>
);
}}
@@ -1376,6 +1374,7 @@ export function CommitMessageField({
const amend = useCommit((s) => s.amend);
const focusTick = useCommit((s) => s.focusTick);
const ref = useRef<HTMLTextAreaElement>(null);
const barRef = useRef<HTMLDivElement>(null);
const [historyOpen, setHistoryOpen] = useState(false);
const historyTick = useCommit((s) => s.historyTick);
const { emptyError } = runner;
@@ -1394,11 +1393,6 @@ export function CommitMessageField({
const cfg = useWorkflowSettings((s) => s.vcs.commit);
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const messageFont = {
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
};
const first = message.split("\n")[0] ?? "";
const tooLong = cfg.limitSubject && first.length > cfg.subjectLimit;
const problems = messageProblems(message, cfg).filter((p) => !p.startsWith("Subject line"));
@@ -1408,7 +1402,7 @@ export function CommitMessageField({
return (
<>
<div className={styles.commitBar}>
<div ref={barRef} className={styles.commitBar}>
<Checkbox checked={amend} onChange={(v) => void setAmend(v)} label="Amend" />
{chooseAmendTarget && amendRoot && <AmendTargetMenu root={amendRoot} />}
<IconButton
@@ -1420,32 +1414,22 @@ export function CommitMessageField({
aria-expanded={historyOpen}
onClick={() => setHistoryOpen((o) => !o)}
/>
<Popup
<Menu
open={historyOpen}
onClose={() => setHistoryOpen(false)}
anchor={ref}
anchor={barRef}
placement="top-start"
offset={3}
role="presentation"
autoFocus={false}
className={styles.messageHistory}
style={{ ...messageFont, ["--history-columns" as string]: `${cfg.subjectLimit}ch` }}
>
<MenuList
onDone={() => setHistoryOpen(false)}
iconColumn={false}
aria-label={tx("Recent commit messages")}
items={history.map((m, i) => ({
id: `h${i}`,
label: m.replace(/\r\n?|\n/g, " ⏎ "),
verbatim: true,
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
</Popup>
iconColumn={false}
aria-label="Recent commit messages"
items={history.map((m, i) => ({
id: `h${i}`,
label: m.split("\n")[0]!.slice(0, 80),
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
<CommitMessageActions />
<span className={styles.grow} />
{tooLong && (
@@ -1461,7 +1445,9 @@ export function CommitMessageField({
aria-invalid={emptyError || undefined}
style={{
["--guide" as string]: `${margin}ch`,
...messageFont,
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
lineHeight: editor?.lineHeight ? `${editor.lineHeight}px` : undefined,
}}
value={message}
+5 -6
View File
@@ -703,16 +703,15 @@
padding-top: 10px;
border-top: 1px solid var(--border);
}
.detailRefGroup {
display: flex;
.meta .refs {
margin-left: 0;
max-width: none;
flex-wrap: wrap;
gap: var(--space-0-5) var(--space-2);
}
.detailRefGroup .ref {
align-items: baseline;
font-size: inherit;
.meta .ref {
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
}
.hash {
font-family: var(--font-mono);
@@ -13,12 +13,7 @@
font-size: var(--fs-ui);
}
.intro {
display: grid;
gap: var(--space-1);
}
.intro p {
.content p {
margin: 0;
}
@@ -26,7 +21,7 @@
display: flex;
flex: 1 1 230px;
flex-direction: column;
min-height: calc(2 * var(--h-row) + var(--h-control));
min-height: 0;
border: 1px solid var(--border);
border-radius: var(--radius-small);
overflow: hidden;
@@ -45,32 +40,13 @@
min-height: var(--h-row);
}
.nodeIcon {
flex: none;
}
.fileLabel {
display: flex;
flex: 1;
align-items: baseline;
gap: var(--space-1-5);
min-width: 0;
}
.fileName,
.directory {
.path {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.directory {
flex: 1;
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.hint {
color: var(--fg-subtle);
}
+26 -31
View File
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import type { CheckoutOptions, FileStatus } from "@/bindings";
import { bindingsFor, normalizeBinding, registerKeyClaim, shortcutLabel } from "@/platform/keymap";
import { Button, Dialog, Icon, IconButton, T, Tree, fileIconName, showContextMenu, type DialogButton } from "@/ui";
import { Dialog, Icon, IconButton, T, Tree, fileIconName, showContextMenu, type DialogButton } from "@/ui";
import { showRollbackDialog } from "./changeOps";
import { isNestedRepoEntry } from "./submoduleRollback";
import { groupOf, isPartiallyStaged } from "./changes";
@@ -9,7 +9,7 @@ import { workingDiffData, withChain } from "./diffInput";
import { openDialog } from "./dialogs";
import { dirKeys, type FileTreeNode } from "./fileTree";
import { filesUnder } from "./logChanges";
import { baseName, dirName, effectiveKind, KIND_COLOR, rootOf } from "./model";
import { baseName, effectiveKind, KIND_COLOR, rootOf } from "./model";
import { repositoryPath } from "./repositoryPaths";
import { refreshNow, repoName, useVcs } from "./store";
import { useWorkflowSettings } from "@/platform/workflowSettings";
@@ -180,6 +180,15 @@ function LocalChangesReviewDialog({
},
{ label: text.cancel, role: "cancel", disabled: rollingBack },
];
if (operation === "checkout") {
buttons.splice(1, 0, {
label: "Force Checkout",
role: "extra",
title: "Discard local changes in affected repositories",
disabled: !blocked || rollingBack,
onClick: () => onDone({ mode: "force", files: visible }),
});
}
return (
<Dialog
open
@@ -192,29 +201,11 @@ function LocalChangesReviewDialog({
minHeight={300}
resizable="both"
buttons={buttons}
footerStart={
operation === "checkout" && (
<Button
title="Discard local changes in affected repositories"
disabled={!blocked || rollingBack}
onClick={() => onDone({ mode: "force", files: visible })}
>
Force Checkout
</Button>
)
}
>
<div ref={content} className={styles.content}>
<div className={styles.intro}>
<p>
<T>{blocked ? text.wouldOverwrite : text.cleared}</T>
</p>
{blocked && !reviewOnly && (
<p className={styles.hint}>
<T>{text[policy]}</T>
</p>
)}
</div>
<p>
<T>{blocked ? text.wouldOverwrite : text.cleared}</T>
</p>
<div className={styles.review}>
<div className={styles.toolbar}>
<IconButton
@@ -278,23 +269,27 @@ function LocalChangesReviewDialog({
className={styles.tree}
renderNode={(node) => {
const file = node.file;
const name = file ? baseName(node.name) : node.name;
const directory = file ? dirName(node.name) : "";
const kind = file?.status && effectiveKind(file.status);
return (
<>
<Icon className={styles.nodeIcon} name={file ? fileIconName(name) : "folder"} size={16} />
<span className={styles.fileLabel} title={node.name}>
<span className={styles.fileName} style={{ color: kind ? KIND_COLOR[kind] : undefined }}>
{name}
</span>
{directory && <span className={styles.directory}>{directory}</span>}
<Icon name={file ? fileIconName(baseName(node.name)) : "folder"} size={16} />
<span
className={styles.path}
title={node.name}
style={{ color: kind ? KIND_COLOR[kind] : undefined }}
>
{node.name}
</span>
</>
);
}}
/>
</div>
{blocked && !reviewOnly && (
<p className={styles.hint}>
<T>{text[policy]}</T>
</p>
)}
</div>
</Dialog>
);
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff. Show more