mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c45e20b6da | ||
|
|
1bb9f8d07c | ||
|
|
a539baec37 | ||
|
|
7dff6e1852 | ||
|
|
fc7fa85850 | ||
|
|
7e5a2cf051 | ||
|
|
c4e08a9676 | ||
|
|
2c0b76c9e6 | ||
|
|
4d1f51c607 | ||
|
|
2215239ecb | ||
|
|
43eeb080be | ||
|
|
03a19d4284 | ||
|
|
3aeee3fcfc | ||
|
|
471003a8c5 | ||
|
|
c109773d2a | ||
|
|
ed6b67faed | ||
|
|
ff7bfcaf1d | ||
|
|
91330a82d0 | ||
|
|
ce75c58a34 | ||
|
|
03b9070b9b | ||
|
|
f6f610516c | ||
|
|
cf49a91b66 | ||
|
|
e0a97e32f7 | ||
|
|
dd0eeeae29 | ||
|
|
4bb22df1fb | ||
|
|
aee087597a | ||
|
|
993a321dd0 | ||
|
|
381e66aca5 | ||
|
|
d7a05eea21 | ||
|
|
c61ddbff3d | ||
|
|
0c20d72cbf | ||
|
|
021f334c0c | ||
|
|
c61264cdf9 | ||
|
|
e4d6f50a0b | ||
|
|
0435e0330e | ||
|
|
13b5f9e575 | ||
|
|
dde4b28abd | ||
|
|
3817724637 | ||
|
|
26b5856ce0 | ||
|
|
6aeb733f20 | ||
|
|
29fcec6ab8 | ||
|
|
5d6c76cdda | ||
|
|
844c2f3145 |
No files matched your search
@@ -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!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
|
||||
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
|
||||
|
||||
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
|
||||
assert_eq!(
|
||||
@@ -63,13 +63,26 @@ 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!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
|
||||
assert!(import_roots(&host, |roots| roots.is_empty()).await.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();
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function show(page: Page, action: string) {
|
||||
await page.evaluate(async (action) => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
if (!(await (await import(/* @vite-ignore */ actions)).executeAction(action))) throw Error(action);
|
||||
}, action);
|
||||
}
|
||||
|
||||
test("analysis scope fields align with their radio choices and retain their values", async ({ workbench: page }) => {
|
||||
await page.evaluate(async () => {
|
||||
const search = "/src/platform/search.ts";
|
||||
(await import(/* @vite-ignore */ search)).saveCustomScopes([
|
||||
{ name: "Frontend", pattern: "file:src//*" },
|
||||
{ name: "Tests", pattern: "file:tests//*" },
|
||||
]);
|
||||
});
|
||||
await show(page, "analyze.inspectCode");
|
||||
const dialog = page.getByRole("dialog", { name: "Specify Inspection Scope" });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
const custom = scope.getByRole("button", { name: "Custom scope", exact: true });
|
||||
const radio = scope.getByRole("radio", { name: "Module or directory" });
|
||||
const label = scope.getByText("Module or directory", { exact: true });
|
||||
|
||||
await radio.check();
|
||||
const path = (await directory.boundingBox())!;
|
||||
const choice = (await label.boundingBox())!;
|
||||
expect(path.y + path.height / 2).toBeCloseTo(choice.y + choice.height / 2, 0);
|
||||
await directory.fill("/dev/acme-api/src");
|
||||
await expect(custom).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(directory).toBeDisabled();
|
||||
expect((await custom.boundingBox())!.x).toBeCloseTo(path.x, 0);
|
||||
await custom.click();
|
||||
await page.getByRole("option", { name: /^Tests/ }).click();
|
||||
await expect(custom).toContainText("Tests");
|
||||
|
||||
await radio.check();
|
||||
await expect(directory).toHaveValue("/dev/acme-api/src");
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(custom).toContainText("Tests");
|
||||
await page.setViewportSize({ width: 400, height: 640 });
|
||||
const stacked = (await directory.boundingBox())!;
|
||||
const customBox = (await custom.boundingBox())!;
|
||||
const radioBox = (await label.boundingBox())!;
|
||||
const next = (await scope.getByText("Current file", { exact: true }).boundingBox())!;
|
||||
expect(stacked.y).toBeGreaterThan(radioBox.y + radioBox.height);
|
||||
expect(stacked.y + stacked.height).toBeLessThan(next.y);
|
||||
expect(stacked.x).toBeCloseTo(customBox.x, 0);
|
||||
expect(await scope.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
for (const [action, title] of [
|
||||
["code.cleanup", "Run Code Cleanup"],
|
||||
["analyze.locateDuplicates", "Locate Duplicates"],
|
||||
["find.structural", "Structural Search"],
|
||||
["find.replaceStructural", "Structural Replace"],
|
||||
] as const) {
|
||||
test(`${title} keeps directory options with their scope choice`, async ({ workbench: page }) => {
|
||||
await show(page, action);
|
||||
const dialog = page.getByRole("dialog", { name: title });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
await expect(directory).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Module or directory" }).check();
|
||||
await expect(directory).toBeEnabled();
|
||||
await expect(scope.getByRole("button", { name: "Browse…" })).toBeEnabled();
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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");
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function showBuild(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
async function showBuild(page: Page, diagnosticPath: string | null = null) {
|
||||
await page.evaluate(async (path) => {
|
||||
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) {
|
||||
{ kind: "out", text: "Compiling TypeScript" },
|
||||
{ kind: "err", text: "Expected a number" },
|
||||
],
|
||||
messages: [{ severity: "error", text: "Expected a number", path: null, range: null, code: null }],
|
||||
messages: [{ severity: "error", text: "Expected a number", path, 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,6 +35,28 @@ 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" });
|
||||
|
||||
@@ -111,6 +111,7 @@ 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.
|
||||
@@ -124,6 +125,37 @@ 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 }) => {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
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");
|
||||
});
|
||||
+223
-10
@@ -85,6 +85,66 @@ 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"]');
|
||||
@@ -720,6 +780,81 @@ test("Commit Options applies a named TODO filter independently of the TODO windo
|
||||
expect(await ipcCalls(page, "vcs_commit")).toEqual([]);
|
||||
});
|
||||
|
||||
test("commit check text scrolls independently of its status icon and retry action", async ({ workbench: page }) => {
|
||||
await stubRepository(page);
|
||||
await page.setViewportSize({ width: 850, height: 650 });
|
||||
await page.evaluate(async () => {
|
||||
const registryPath = "/src/features/vcs/commitCheckRegistry.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { registerCommitCheck } = await import(/* @vite-ignore */ registryPath);
|
||||
const layout = await import(/* @vite-ignore */ layoutPath);
|
||||
layout.moveToolWindow("commit", "left");
|
||||
layout.setToolWindowSize("left", 238);
|
||||
for (let index = 0; index < 6; index++) {
|
||||
registerCommitCheck({
|
||||
id: `test.commitLayout.${index}`,
|
||||
order: index - 1000,
|
||||
title: `Ledger check ${index + 1}`,
|
||||
run: () => {
|
||||
if (index === 0) document.body.dataset.checkRuns = String(Number(document.body.dataset.checkRuns ?? 0) + 1);
|
||||
return {
|
||||
severity: "error",
|
||||
text: "The regional settlement totals differ from the monthly inventory audit and need a second review.",
|
||||
fix:
|
||||
index === 5
|
||||
? {
|
||||
label: "Review final check",
|
||||
run: () => {
|
||||
document.body.dataset.commitCheckReviewed = "yes";
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
await page.keyboard.press("Meta+k");
|
||||
const commit = page.getByRole("region", { name: "Commit", exact: true });
|
||||
await commit.getByRole("textbox", { name: "Commit message" }).fill("Review the settlement totals");
|
||||
await commit.getByRole("button", { name: "Commit Options", exact: true }).click();
|
||||
const options = page.getByRole("dialog", { name: "Commit Options", exact: true });
|
||||
await options.getByRole("button", { name: "Run Commit Checks", exact: true }).click();
|
||||
|
||||
const feedback = commit.getByRole("alert").filter({ hasText: "Ledger check 1" });
|
||||
const first = feedback.getByText("Ledger check 1", { exact: true });
|
||||
const second = feedback.getByText("Ledger check 2", { exact: true });
|
||||
const results = first.locator("../..");
|
||||
const icon = feedback.locator("svg").first();
|
||||
const retry = commit.getByRole("button", { name: "Rerun Commit Checks", exact: true });
|
||||
const commitAnyway = commit.getByRole("button", { name: "Commit Anyway", exact: true });
|
||||
await expect(commitAnyway).toBeInViewport({ ratio: 1 });
|
||||
await expect(first).toHaveCSS("font-size", "13px");
|
||||
const firstRow = (await first.locator("..").boundingBox())!;
|
||||
const secondRow = (await second.locator("..").boundingBox())!;
|
||||
expect(secondRow.y - (firstRow.y + firstRow.height)).toBeCloseTo(4, 0);
|
||||
expect(await results.evaluate((node) => node.scrollHeight > node.clientHeight)).toBe(true);
|
||||
const statusTop = (await icon.boundingBox())!.y;
|
||||
const retryTop = (await retry.boundingBox())!.y;
|
||||
await results.evaluate((node) => {
|
||||
node.scrollTop = node.scrollHeight;
|
||||
});
|
||||
expect(await results.evaluate((node) => node.scrollTop)).toBeGreaterThan(0);
|
||||
expect((await icon.boundingBox())!.y).toBeCloseTo(statusTop, 0);
|
||||
expect((await retry.boundingBox())!.y).toBeCloseTo(retryTop, 0);
|
||||
const details = feedback.getByRole("button", { name: "Review final check", exact: true });
|
||||
await expect(details).toBeInViewport({ ratio: 1 });
|
||||
await expect(icon).toBeInViewport({ ratio: 1 });
|
||||
await expect(retry).toBeInViewport({ ratio: 1 });
|
||||
await expect(commitAnyway).toBeInViewport({ ratio: 1 });
|
||||
await details.click();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-commit-check-reviewed", "yes");
|
||||
await retry.click();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-check-runs", "2");
|
||||
await expect(first).toBeVisible();
|
||||
expect(await ipcCalls(page, "vcs_commit")).toEqual([]);
|
||||
});
|
||||
|
||||
test("the TODO check reports unreadable files and can retry after they become available", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
@@ -1024,27 +1159,51 @@ test("the Commit tool window restores the draft and author options for the inclu
|
||||
await expect(message).toHaveValue("Default draft");
|
||||
});
|
||||
|
||||
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
|
||||
test("commit message history shows compact message previews above the editor", async ({ workbench: page }) => {
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
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(["Previous commit message"]));
|
||||
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}`),
|
||||
]),
|
||||
);
|
||||
}, ROOT);
|
||||
await message.fill("Draft");
|
||||
await page.getByRole("button", { name: "Commit Message History" }).click();
|
||||
const history = page.getByRole("button", { name: "Commit Message History" });
|
||||
await history.click();
|
||||
|
||||
const menu = page.getByRole("menu", { name: "Recent commit messages" });
|
||||
const row = menu.getByRole("menuitem", { name: "Previous commit message" });
|
||||
const row = menu.getByRole("menuitem", { name: /Update inventory.*Review settlement totals/ });
|
||||
await expect(row).toBeVisible();
|
||||
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);
|
||||
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));
|
||||
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 }) => {
|
||||
@@ -1155,6 +1314,60 @@ 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");
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, PROJECT, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Coverage keeps sortable statistics aligned next to the file tree at sidebar widths", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
async function importCoverage(page: Page, width: number) {
|
||||
await page.setViewportSize({ width: 1050, height: 550 });
|
||||
await expect(page.getByRole("tree", { name: "Project" }).getByRole("treeitem", { name: PROJECT })).toBeVisible();
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
await page.evaluate(async (width) => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
@@ -26,10 +27,15 @@ test("Coverage keeps sortable statistics aligned next to the file tree at sideba
|
||||
hasBranches: path === "/tmp/coverage.lcov",
|
||||
files,
|
||||
});
|
||||
setToolWindowSize("right", 280);
|
||||
setToolWindowSize("right", width);
|
||||
await executeAction("coverage.importReport", "/tmp/coverage.lcov");
|
||||
});
|
||||
}, width);
|
||||
}
|
||||
|
||||
test("Coverage keeps sortable statistics aligned next to the file tree at sidebar widths", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await importCoverage(page, 280);
|
||||
const coverage = page.getByRole("region", { name: "Coverage", exact: true });
|
||||
const tree = coverage.getByRole("tree", { name: "Coverage" });
|
||||
const line = coverage.getByRole("columnheader", { name: "Line, %" });
|
||||
@@ -70,3 +76,58 @@ test("Coverage keeps sortable statistics aligned next to the file tree at sideba
|
||||
await expect(line).toBeVisible();
|
||||
expect((await ready.getByTitle("100% (20/20)").boundingBox())!.x).toBeCloseTo((await line.boundingBox())!.x, 0);
|
||||
});
|
||||
|
||||
test("Coverage column widths follow the dividers and survive a narrower dock and reload", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await importCoverage(page, 460);
|
||||
const coverage = page.getByRole("region", { name: "Coverage", exact: true });
|
||||
const line = coverage.getByRole("columnheader", { name: "Line, %" });
|
||||
const branch = coverage.getByRole("columnheader", { name: "Branch, %" });
|
||||
const lineDivider = coverage.getByRole("separator", { name: "Resize Line, % column" });
|
||||
const branchDivider = coverage.getByRole("separator", { name: "Resize Branch, % column" });
|
||||
const ready = coverage.getByRole("treeitem", { name: /^Ready\.ts/ });
|
||||
const nameHeader = coverage.getByRole("columnheader", { name: "Element" });
|
||||
await expect(lineDivider).toBeVisible();
|
||||
const width = async (loc: typeof line) => (await loc.boundingBox())!.width;
|
||||
const originalLine = await width(line);
|
||||
const originalBranch = await width(branch);
|
||||
const originalName = await width(nameHeader);
|
||||
const drag = (await lineDivider.boundingBox())!;
|
||||
await page.mouse.move(drag.x + drag.width / 2, drag.y + drag.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(drag.x + drag.width / 2 + 32, drag.y + drag.height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 32, 0);
|
||||
await expect.poll(() => width(nameHeader)).toBeCloseTo(originalName + 32, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch, 0);
|
||||
await expect(line).toHaveAttribute("aria-sort", "none");
|
||||
|
||||
await branchDivider.press("ArrowRight");
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
expect((await ready.getByTitle("100% (20/20)").boundingBox())!.x).toBeCloseTo((await line.boundingBox())!.x, 0);
|
||||
|
||||
const resizeDock = (size: number) =>
|
||||
page.evaluate(async (size) => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
setToolWindowSize("right", size);
|
||||
}, size);
|
||||
await resizeDock(240);
|
||||
await expect.poll(() => width(line)).toBeLessThan(originalLine - 22);
|
||||
const tree = coverage.getByRole("tree", { name: "Coverage" });
|
||||
await expect.poll(() => tree.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await expect(branchDivider).toBeInViewport({ ratio: 1 });
|
||||
await resizeDock(460);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
|
||||
await page.reload();
|
||||
await importCoverage(page, 460);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
await branchDivider.dblclick();
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch, 0);
|
||||
});
|
||||
@@ -3,6 +3,7 @@
|
||||
* 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";
|
||||
@@ -114,6 +115,83 @@ 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);
|
||||
|
||||
@@ -88,3 +88,40 @@ 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);
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
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);
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
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();
|
||||
});
|
||||
@@ -1,6 +1,66 @@
|
||||
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,11 +3,12 @@ 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);
|
||||
await page.evaluate(async () => {
|
||||
const longEmail = `reconciliation+${"regional-settlement-".repeat(5)}[email protected]`;
|
||||
await page.evaluate(async (email) => {
|
||||
const root = "/dev/acme-api";
|
||||
const file = `${root}/build.gradle.kts`;
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.vcs_blame = () => [
|
||||
const lines = [
|
||||
{
|
||||
commit: "a1234567".padEnd(40, "a"),
|
||||
author: "Lena Park",
|
||||
@@ -21,6 +22,23 @@ 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();
|
||||
@@ -39,7 +57,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" });
|
||||
@@ -51,6 +69,21 @@ 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);
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
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");
|
||||
});
|
||||
@@ -12,6 +12,30 @@ 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,
|
||||
}) => {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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();
|
||||
});
|
||||
@@ -83,6 +83,10 @@ 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();
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
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();
|
||||
});
|
||||
+35
-2
@@ -11,7 +11,7 @@ async function openNewBranchDialog(
|
||||
page: Page,
|
||||
from?: string,
|
||||
mergeBase = "1111111",
|
||||
blocked = false,
|
||||
blocked: boolean | string = false,
|
||||
withPrefix = false,
|
||||
) {
|
||||
await stubDesktop(page);
|
||||
@@ -43,7 +43,10 @@ async function openNewBranchDialog(
|
||||
];
|
||||
h.vcs_create_branch = ({ options }) =>
|
||||
blocked && (options as { mode?: string } | null)?.mode === "normal"
|
||||
? { checkout: { kind: "localChanges", files: ["dirty.txt"] }, created: null }
|
||||
? {
|
||||
checkout: { kind: "localChanges", files: [typeof blocked === "string" ? blocked : "dirty.txt"] },
|
||||
created: null,
|
||||
}
|
||||
: { checkout: { kind: "done" }, created: { tip: "2222222", previousTip: null } };
|
||||
h.vcs_merge_base = () => mergeBase;
|
||||
const vcsModule = "/src/features/vcs/store.ts";
|
||||
@@ -151,6 +154,36 @@ 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("");
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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();
|
||||
});
|
||||
@@ -1,9 +1,7 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Quick Evaluate opens an object tree that fits the editor and returns focus on Escape", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
test("Quick Evaluate and hover keep value previews usable in a narrow editor", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 445, height: 500 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
@@ -19,7 +17,9 @@ test("Quick Evaluate opens an object tree that fits the editor and returns focus
|
||||
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", "{...}", "dict", 101) : value("subtotal", "42", "int");
|
||||
expression === "summary"
|
||||
? value("summary", `{'audit': '${"Regional settlement totals ".repeat(8)}'}`, "dict", 101)
|
||||
: value("subtotal", "42", "int");
|
||||
h.debug_variables = ({ reference }) =>
|
||||
reference === 101
|
||||
? [value("audit", "{...}", "dict", 102), value("total", "47.74", "float")]
|
||||
@@ -81,8 +81,59 @@ test("Quick Evaluate opens an object tree that fits the editor and returns focus
|
||||
await evaluate(2);
|
||||
await expect(hint.getByRole("tree")).toHaveCount(0);
|
||||
await expect(hint).toHaveText(/subtotal\s*=\s*42/);
|
||||
expect(await ipcCalls(page, "debug_evaluate_in")).toEqual([
|
||||
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([
|
||||
{ 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" });
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
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);
|
||||
});
|
||||
@@ -581,3 +581,54 @@ 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" });
|
||||
});
|
||||
+152
-20
@@ -1,39 +1,145 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { BeforeLaunchTask } from "../src/bindings";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function openConfigurations(page: Page, target?: string) {
|
||||
await page.evaluate(async (target) => {
|
||||
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) => {
|
||||
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: [{ kind: "run", target: "layout:prepare" }],
|
||||
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:prepare", name: "Prepare generated sources for the payments development server" },
|
||||
],
|
||||
selectedId: "layout:app",
|
||||
editTarget: "layout:jvm",
|
||||
loaded: true,
|
||||
editorOpen: true,
|
||||
});
|
||||
}, target);
|
||||
}, 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 },
|
||||
);
|
||||
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);
|
||||
@@ -55,6 +161,32 @@ 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,
|
||||
}) => {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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" } }]);
|
||||
});
|
||||
@@ -1,4 +1,64 @@
|
||||
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 }) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ async function run(page: Page, id: string) {
|
||||
}, id);
|
||||
}
|
||||
|
||||
async function stubFindMatches(page: Page) {
|
||||
async function stubFindMatches(page: Page, firstPath = LONG_RESULT_PATH) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate((longPath) => {
|
||||
window.__ipc.handlers.search_validate = () => null;
|
||||
@@ -39,7 +39,7 @@ async function stubFindMatches(page: Page) {
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
}, LONG_RESULT_PATH);
|
||||
}, firstPath);
|
||||
}
|
||||
|
||||
async function expectControlsFit(page: Page) {
|
||||
@@ -205,3 +205,29 @@ 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");
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
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//*");
|
||||
});
|
||||
@@ -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"]) {
|
||||
for (const id of ["appearance", "editor.font", "general", "general.httpProxy", "vcs.log"]) {
|
||||
await selectPage(page, id);
|
||||
const body = page.locator("[class*='pageBody']");
|
||||
for (const width of [1000, 784, 640, 520]) {
|
||||
@@ -108,6 +108,31 @@ 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 });
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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();
|
||||
});
|
||||
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
});
|
||||
@@ -102,6 +102,9 @@ 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();
|
||||
|
||||
@@ -1,5 +1,41 @@
|
||||
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"]');
|
||||
|
||||
+22
-4
@@ -71,7 +71,15 @@ 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");
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText(/\d+\/3/);
|
||||
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();
|
||||
if (process.env.OPENIDEA_TERMINAL_SHOTS)
|
||||
await terminal.screenshot({
|
||||
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/terminal-${width}${split ? "-split" : ""}.png`,
|
||||
@@ -83,9 +91,19 @@ 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);
|
||||
}
|
||||
expect((await input.boundingBox())!.width).toBeGreaterThan(40);
|
||||
|
||||
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);
|
||||
|
||||
await matchCase.focus();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(matchCase).toHaveAttribute("aria-pressed", "true");
|
||||
@@ -130,7 +148,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(before.width);
|
||||
expect(top.width).toBeLessThan(420);
|
||||
|
||||
await input.fill("right-edge");
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText("1/1");
|
||||
|
||||
@@ -143,10 +143,6 @@
|
||||
gap: var(--space-0-5);
|
||||
padding: 0 6px 0 8px;
|
||||
}
|
||||
.pin {
|
||||
color: var(--fg-muted);
|
||||
margin-left: -2px;
|
||||
}
|
||||
.deprecated {
|
||||
text-decoration-line: line-through;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import { useFileColors } from "@/workbench/fileColors";
|
||||
import { EmptyEditor } from "@/workbench/EditorArea";
|
||||
import {
|
||||
EmptyState,
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
SplitGroup,
|
||||
@@ -216,7 +215,6 @@ 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;
|
||||
@@ -242,6 +240,7 @@ 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
|
||||
@@ -252,13 +251,7 @@ 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 || pin ? (
|
||||
<>
|
||||
{kindMark}
|
||||
{pin}
|
||||
</>
|
||||
) : undefined,
|
||||
trailing: kindMark,
|
||||
};
|
||||
});
|
||||
}, [
|
||||
@@ -369,6 +362,7 @@ 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.
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
* 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, searchHistory } from "@/platform/search";
|
||||
import { SEARCH_CONTEXTS, rememberSearch } from "@/platform/search";
|
||||
import { editorController, useFindBars, useTabs } from "../controller";
|
||||
import {
|
||||
countMatches,
|
||||
@@ -557,19 +558,6 @@ 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",
|
||||
@@ -765,12 +753,10 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<Menu
|
||||
open={historyMenu !== null}
|
||||
<SearchHistoryMenu
|
||||
kind={historyMenu}
|
||||
anchor={historyMenu === "replace" ? replaceBoxRef : findBoxRef}
|
||||
items={historyMenu ? historyItems(historyMenu) : []}
|
||||
placement="bottom-start"
|
||||
aria-label="Recent searches"
|
||||
onSelect={(value) => setOpts(historyMenu === "replace" ? { replace: value } : { search: value })}
|
||||
onClose={() => setHistoryMenu(null)}
|
||||
/>
|
||||
<Menu
|
||||
|
||||
@@ -417,6 +417,11 @@ 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();
|
||||
@@ -454,12 +459,12 @@ export function LineEndingStatus() {
|
||||
onClose={() => setOpen(false)}
|
||||
anchor={ref}
|
||||
placement="top-end"
|
||||
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),
|
||||
title="Line Separator"
|
||||
items={EOL_CHOICES.map(({ id, label }) => ({
|
||||
id,
|
||||
label,
|
||||
checked: meta.lineEnding === id ? true : undefined,
|
||||
run: () => choose(id),
|
||||
}))}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1045,6 +1045,7 @@ 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.
|
||||
|
||||
+21
-8
@@ -212,22 +212,28 @@ 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",
|
||||
@@ -490,7 +496,14 @@ 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": { overflowWrap: "anywhere" },
|
||||
".cm-lsp-inplace-footer": {
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
padding: "5px 12px",
|
||||
gap: "var(--space-1) var(--space-3)",
|
||||
justifyContent: "space-between",
|
||||
overflowWrap: "anywhere",
|
||||
},
|
||||
|
||||
// --- floating lightbulb (intentions.ts) -----------------------------------
|
||||
".cm-lsp-bulb": {
|
||||
|
||||
@@ -161,34 +161,51 @@
|
||||
padding: 14px;
|
||||
}
|
||||
.scope {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-0-5);
|
||||
container: analysis-scope / inline-size;
|
||||
min-inline-size: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.scopeOptions {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(45%) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
}
|
||||
.fieldLabel {
|
||||
padding: 0 0 4px;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.radioRow {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
padding-block: var(--space-0-5);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.scopeWithField {
|
||||
grid-column: 1;
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: 3px 0;
|
||||
color: var(--fg);
|
||||
cursor: default;
|
||||
}
|
||||
.radioRow input {
|
||||
margin: 0;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
.dirRow {
|
||||
display: flex;
|
||||
gap: var(--space-1-5);
|
||||
padding: 4px 0 0 22px;
|
||||
min-width: 0;
|
||||
}
|
||||
.scopeControl > button:last-child {
|
||||
flex: none;
|
||||
}
|
||||
@container analysis-scope (max-width: 336px) {
|
||||
.scopeOptions {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 1;
|
||||
padding-inline-start: calc(16px + var(--space-2));
|
||||
margin-block-end: var(--space-1);
|
||||
}
|
||||
}
|
||||
.grow {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/** Dialog stack of the analysis feature and the shared "Specify Scope" fields. */
|
||||
import { Fragment, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { create } from "zustand";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { isTauri } from "@/platform/ipc";
|
||||
import { EDIT_SCOPES_ACTION, useCustomScopeList } from "@/platform/search";
|
||||
import { Button, IconButton, Input, Select, T } from "@/ui";
|
||||
import { Button, IconButton, Input, Radio, Select, T } from "@/ui";
|
||||
import { SCOPE_LABELS, currentFile, type ScopeChoice, type ScopeKind } from "./scope";
|
||||
import styles from "./Analysis.module.css";
|
||||
|
||||
@@ -62,57 +63,69 @@ export function ScopeFields({
|
||||
}) {
|
||||
const file = currentFile();
|
||||
const scopes = useCustomScopeList();
|
||||
const custom = value.custom ?? scopes[0]?.name;
|
||||
return (
|
||||
<fieldset className={styles.scope}>
|
||||
<legend className={styles.fieldLabel}>
|
||||
<T>Scope</T>
|
||||
</legend>
|
||||
{kinds.map((kind) => (
|
||||
<label key={kind} className={styles.radioRow}>
|
||||
<input
|
||||
type="radio"
|
||||
name={name}
|
||||
checked={value.kind === kind}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() =>
|
||||
onChange({ ...value, kind, custom: kind === "custom" ? (value.custom ?? scopes[0]?.name) : value.custom })
|
||||
}
|
||||
/>
|
||||
<span>{kind === "file" && file ? tx`File '${file.split("/").pop()}'` : tx(SCOPE_LABELS[kind])}</span>
|
||||
</label>
|
||||
))}
|
||||
{value.kind === "directory" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{value.kind === "custom" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={value.custom ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder="No custom scopes"
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, value.custom ? { select: value.custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.scopeOptions}>
|
||||
{kinds.map((kind) => {
|
||||
const selected = value.kind === kind;
|
||||
return (
|
||||
<Fragment key={kind}>
|
||||
<Radio
|
||||
name={name}
|
||||
checked={selected}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() => onChange({ ...value, kind, custom: kind === "custom" ? custom : value.custom })}
|
||||
label={
|
||||
kind === "file" && file ? <span>{tx`File '${file.split("/").pop()}'`}</span> : SCOPE_LABELS[kind]
|
||||
}
|
||||
className={clsx(styles.radioRow, (kind === "directory" || kind === "custom") && styles.scopeWithField)}
|
||||
/>
|
||||
{kind === "directory" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
disabled={!selected}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
disabled={!selected}
|
||||
onClick={() =>
|
||||
void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))
|
||||
}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{kind === "custom" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={(selected ? value.custom : custom) ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder={scopes.length ? "Choose a scope" : "No custom scopes"}
|
||||
disabled={!selected}
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
disabled={!selected}
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, custom ? { select: custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
mavenRoots,
|
||||
nodeIcon,
|
||||
nodeLabel,
|
||||
pluginCoordinates,
|
||||
profileChecked,
|
||||
withGradleOptions,
|
||||
gradleHasTestTask,
|
||||
@@ -310,6 +311,8 @@ 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()
|
||||
@@ -317,18 +320,28 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
? `(${node.dependency.scope}${node.dependency.optional ? ", optional" : ""})`
|
||||
: node.kind === "dependency" && node.dependency.optional
|
||||
? "(optional)"
|
||||
: node.kind === "task"
|
||||
? node.task.description
|
||||
: null;
|
||||
: 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} title={node.kind === "task" ? (node.task.description ?? undefined) : undefined}>
|
||||
<span className={styles.row}>
|
||||
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{nodeLabel(node)}
|
||||
</span>
|
||||
{coordinates ? (
|
||||
<span className={styles.pluginText}>
|
||||
{label}
|
||||
<span className={styles.detail} title={coordinates}>
|
||||
{coordinates}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
{detail && <span className={styles.detail}>{detail}</span>}
|
||||
</span>
|
||||
);
|
||||
@@ -475,6 +488,7 @@ 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,6 +96,18 @@
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
|
||||
return parts.join(":");
|
||||
}
|
||||
|
||||
export function pluginLabel(p: MavenPlugin): string {
|
||||
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
|
||||
export function pluginCoordinates(p: MavenPlugin): string {
|
||||
return `${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 pluginLabel(node.plugin);
|
||||
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
|
||||
case "goal":
|
||||
return `${node.plugin.prefix}:${node.goal}`;
|
||||
case "dependencies":
|
||||
|
||||
@@ -30,6 +30,16 @@
|
||||
.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);
|
||||
}
|
||||
@@ -37,6 +47,26 @@
|
||||
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);
|
||||
|
||||
@@ -67,13 +67,12 @@ function StatusIcon({ status }: { status: BuildStatus }) {
|
||||
return <Icon name={name} size={14} className={styles[`status-${status}`]} />;
|
||||
}
|
||||
|
||||
function rootDetail(status: BuildStatus, durationMs: number | null, errors: number, warnings: number): string {
|
||||
function rootDetail(status: BuildStatus, errors: number, warnings: number): string {
|
||||
if (status === "running") return "running…";
|
||||
if (status === "cancelled") return "cancelled";
|
||||
const summary = finishSummary({ success: status === "success", errors, warnings, durationMs });
|
||||
return status === "success"
|
||||
? `finished ${formatDuration(durationMs ?? 0)}`
|
||||
: summary.replace(/^Build failed:?\s*/, "") || "failed";
|
||||
if (status === "success") return tx("Finished");
|
||||
const summary = finishSummary({ success: false, errors, warnings, durationMs: null });
|
||||
return summary.replace(/^Build failed:?\s*/, "") || "failed";
|
||||
}
|
||||
|
||||
export function BuildHeaderActions() {
|
||||
@@ -130,15 +129,19 @@ 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}>
|
||||
<span className={styles.row} title={[n.title, detail, elapsed].filter(Boolean).join(" ")}>
|
||||
<StatusIcon status={n.status} />
|
||||
<span className={styles.strong}>{n.title}</span>
|
||||
<span className={styles.muted}>{rootDetail(n.status, durationMs, n.errors, n.warnings)}</span>
|
||||
<span className={clsx(styles.muted, styles.rootDetail)}>{detail}</span>
|
||||
{elapsed && <span className={clsx(styles.muted, styles.duration)}>{elapsed}</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 = [
|
||||
@@ -148,13 +151,22 @@ function BuildTree() {
|
||||
.filter(Boolean)
|
||||
.join(", ");
|
||||
return (
|
||||
<span className={styles.row}>
|
||||
<span className={styles.row} title={n.path}>
|
||||
<Icon name={fileIconName(basename(n.path), n.path)} size={16} className={styles.fileIcon} />
|
||||
<span className={clsx(styles.strong, errors > 0 && styles.fileError, state.selected && styles.selected)}>
|
||||
{basename(n.path)}
|
||||
<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>
|
||||
<span className={styles.muted}>{relativeDir(root, n.path)}</span>
|
||||
<span className={styles.muted}>{counts}</span>
|
||||
{counts && <span className={styles.muted}>{counts}</span>}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
padding: 3px 6px;
|
||||
flex-shrink: 0;
|
||||
flex: none;
|
||||
}
|
||||
.vertical {
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
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";
|
||||
@@ -45,11 +47,16 @@ 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 }: { items: readonly Usage[] }) {
|
||||
export function UsageAccessFilter({ items, vertical }: { items: readonly Usage[]; vertical?: boolean }) {
|
||||
const tx = useTx();
|
||||
const options = useUsageAccessOptions();
|
||||
if (!supportsUsageAccess(items)) return null;
|
||||
return (
|
||||
<div className={styles.toolbar} role="toolbar" aria-label="Usage access filters">
|
||||
<div
|
||||
className={clsx(styles.toolbar, vertical && styles.vertical)}
|
||||
role={vertical ? "group" : "toolbar"}
|
||||
aria-label={tx("Usage access filters")}
|
||||
>
|
||||
<IconButton
|
||||
icon="show-read-access"
|
||||
size="small"
|
||||
|
||||
@@ -176,6 +176,7 @@ function UsagesPopupInner() {
|
||||
</span>
|
||||
</span>
|
||||
<div className={styles.actions}>
|
||||
<UsageAccessFilter items={all} />
|
||||
{scope && (
|
||||
<Select<UsageScope>
|
||||
variant="ghost"
|
||||
@@ -213,7 +214,6 @@ function UsagesPopupInner() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<UsageAccessFilter items={all} />
|
||||
{note && (
|
||||
<div className={styles.note} data-testid="usages-note">
|
||||
{note}
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
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;
|
||||
@@ -66,7 +69,6 @@
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
.body > [role="toolbar"],
|
||||
.body > .summary {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
@@ -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("toolbar", { name: "Usage access filters" })).toBeNull();
|
||||
expect(screen.queryByRole("group", { name: "Usage access filters" })).toBeNull();
|
||||
view.unmount();
|
||||
useUsageAccessOptions.setState({ read: true, write: true });
|
||||
useUsages.setState({ tabs: [], active: null });
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { tx, txPart } from "@/platform/i18n";
|
||||
import { lockDragCursor } from "@/ui/dragCursor";
|
||||
import styles from "./Coverage.module.css";
|
||||
|
||||
export function ColumnDivider({
|
||||
title,
|
||||
width,
|
||||
min,
|
||||
max,
|
||||
onResize,
|
||||
onReset,
|
||||
}: {
|
||||
title: string;
|
||||
width: number;
|
||||
min: number;
|
||||
max: number;
|
||||
onResize: (width: number) => void;
|
||||
onReset: () => void;
|
||||
}) {
|
||||
const drag = useRef<{ x: number; width: number; pointerId: number; unlock: () => void } | null>(null);
|
||||
const stop = () => {
|
||||
drag.current?.unlock();
|
||||
drag.current = null;
|
||||
};
|
||||
useEffect(() => stop, []);
|
||||
|
||||
const resize = (next: number) => {
|
||||
const fitted = Math.round(Math.max(min, Math.min(max, next)));
|
||||
if (fitted !== width) onResize(fitted);
|
||||
};
|
||||
|
||||
return (
|
||||
<span
|
||||
className={styles.divider}
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
aria-label={tx`Resize ${txPart(title)} column`}
|
||||
aria-valuemin={min}
|
||||
aria-valuemax={max}
|
||||
aria-valuenow={width}
|
||||
tabIndex={0}
|
||||
onPointerDown={(event) => {
|
||||
if (event.button !== 0 || drag.current) return;
|
||||
event.currentTarget.setPointerCapture(event.pointerId);
|
||||
drag.current = { x: event.clientX, width, pointerId: event.pointerId, unlock: lockDragCursor("col-resize") };
|
||||
}}
|
||||
onPointerMove={(event) => {
|
||||
const start = drag.current;
|
||||
if (start?.pointerId === event.pointerId) resize(start.width + start.x - event.clientX);
|
||||
}}
|
||||
onLostPointerCapture={stop}
|
||||
onDoubleClick={onReset}
|
||||
onKeyDown={(event) => {
|
||||
let next: number;
|
||||
switch (event.key) {
|
||||
case "ArrowLeft":
|
||||
next = width + 10;
|
||||
break;
|
||||
case "ArrowRight":
|
||||
next = width - 10;
|
||||
break;
|
||||
case "Home":
|
||||
next = min;
|
||||
break;
|
||||
case "End":
|
||||
next = max;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
resize(next);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
.view {
|
||||
--coverage-metrics: 2;
|
||||
--coverage-metric-width: min(29cqi, 128px);
|
||||
--coverage-tracks: minmax(0, 1fr) var(--coverage-lines-width) var(--coverage-branches-width);
|
||||
--coverage-column-gap: var(--space-2);
|
||||
container-type: inline-size;
|
||||
height: 100%;
|
||||
@@ -10,6 +10,7 @@
|
||||
}
|
||||
.noBranches {
|
||||
--coverage-metrics: 1;
|
||||
--coverage-tracks: minmax(0, 1fr) var(--coverage-lines-width);
|
||||
}
|
||||
.tabs {
|
||||
min-width: 0;
|
||||
@@ -25,7 +26,7 @@
|
||||
.header,
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) repeat(var(--coverage-metrics), var(--coverage-metric-width));
|
||||
grid-template-columns: var(--coverage-tracks);
|
||||
align-items: center;
|
||||
column-gap: var(--coverage-column-gap);
|
||||
font-size: var(--fs-ui);
|
||||
@@ -44,9 +45,16 @@
|
||||
.header::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
}
|
||||
.heading {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.headerCell {
|
||||
display: inline-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: var(--space-0-5);
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
@@ -63,13 +71,33 @@
|
||||
.headerCell svg {
|
||||
flex: none;
|
||||
}
|
||||
.divider {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
inset-inline-start: calc(-1 * var(--coverage-column-gap));
|
||||
width: var(--coverage-column-gap);
|
||||
cursor: col-resize;
|
||||
touch-action: none;
|
||||
}
|
||||
.divider::after {
|
||||
position: absolute;
|
||||
inset: var(--space-1) 50% var(--space-1) auto;
|
||||
width: 1px;
|
||||
background: var(--border);
|
||||
content: "";
|
||||
}
|
||||
.divider:hover::after,
|
||||
.divider:focus-visible::after,
|
||||
.divider:active::after {
|
||||
background: var(--accent);
|
||||
}
|
||||
.tree {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
/* Keep the chevron and icon in the name column at deeper levels. */
|
||||
--coverage-max-row-inset: max(
|
||||
4px,
|
||||
calc(100% - var(--coverage-metrics) * (var(--coverage-metric-width) + var(--coverage-column-gap)) - 72px)
|
||||
calc(100% - var(--coverage-stats-width) - var(--coverage-metrics) * var(--coverage-column-gap) - 72px)
|
||||
);
|
||||
}
|
||||
.row {
|
||||
@@ -99,16 +127,15 @@
|
||||
@container (width < 360px) {
|
||||
.header,
|
||||
.tree {
|
||||
--coverage-metric-width: min(23cqi, 65px);
|
||||
--coverage-column-gap: var(--space-1);
|
||||
}
|
||||
.count {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
}
|
||||
}
|
||||
.compactCount {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
}
|
||||
.link {
|
||||
padding: 0;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/** Coverage tool window: one tab per recent suite, a sortable tree of directories and files. */
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState, type CSSProperties } from "react";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { EmptyState, Icon, IconButton, Tabs, Tree, fileIconName, T } from "@/ui";
|
||||
import { editorService } from "@/workbench/contributions";
|
||||
import { ColumnDivider } from "./ColumnDivider";
|
||||
import { coverageColumns, readCoverageWidths, saveCoverageWidths } from "./columns";
|
||||
import { coverageTree, formatPercent, sortTree, type CoverageNode, type SortKey } from "./model";
|
||||
import { activeSuite, closeSuite, selectSuite, setCoverageVisible, useCoverage } from "./store";
|
||||
import styles from "./Coverage.module.css";
|
||||
@@ -50,13 +52,13 @@ export function CoverageHeaderActions() {
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({ covered, total }: { covered: number; total: number }) {
|
||||
function Metric({ covered, total, compact }: { covered: number; total: number; compact: boolean }) {
|
||||
const value = formatPercent(covered, total);
|
||||
const [percentage, count] = value.split(" ", 2);
|
||||
return (
|
||||
<span className={styles.value} title={value}>
|
||||
{percentage}
|
||||
{count && <span className={styles.count}> {count}</span>}
|
||||
{count && <span className={compact ? styles.compactCount : undefined}> {count}</span>}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -74,6 +76,16 @@ export function CoverageView() {
|
||||
const root = useProject((s) => s.project?.root ?? "");
|
||||
const [sort, setSort] = useState<{ key: SortKey; ascending: boolean }>({ key: "name", ascending: true });
|
||||
const [expanded, setExpanded] = useState<Set<string> | null>(null);
|
||||
const [pane, setPane] = useState<HTMLDivElement | null>(null);
|
||||
const [paneWidth, setPaneWidth] = useState(0);
|
||||
const [preferred, setPreferred] = useState(readCoverageWidths);
|
||||
useEffect(() => {
|
||||
if (!pane) return;
|
||||
const observer = new ResizeObserver(() => setPaneWidth(pane.clientWidth));
|
||||
observer.observe(pane);
|
||||
return () => observer.disconnect();
|
||||
}, [pane]);
|
||||
useEffect(() => saveCoverageWidths(preferred), [preferred]);
|
||||
|
||||
const roots = useMemo(
|
||||
() => (suite ? sortTree(coverageTree(suite.data, root), sort.key, sort.ascending) : []),
|
||||
@@ -103,11 +115,21 @@ export function CoverageView() {
|
||||
}
|
||||
const branches = suite.data.hasBranches;
|
||||
const columns = branches ? COLUMNS : COLUMNS.slice(0, 2);
|
||||
const { min, budget, widths } = coverageColumns(paneWidth, branches, preferred);
|
||||
const statsWidth = widths.lines + widths.branches;
|
||||
const columnStyle = {
|
||||
"--coverage-lines-width": `${widths.lines}px`,
|
||||
"--coverage-branches-width": `${widths.branches}px`,
|
||||
"--coverage-stats-width": `${statsWidth}px`,
|
||||
} as CSSProperties;
|
||||
const toggleSort = (key: SortKey) =>
|
||||
setSort((s) => (s.key === key ? { key, ascending: !s.ascending } : { key, ascending: key === "name" }));
|
||||
const resizeLines = (lines: number) =>
|
||||
setPreferred((old) => ({ ...old, lines, ...(branches && { branches: widths.branches }) }));
|
||||
const resizeBranches = (width: number) => setPreferred({ lines: statsWidth - width, branches: width });
|
||||
|
||||
return (
|
||||
<div className={clsx(styles.view, !branches && styles.noBranches)}>
|
||||
<div ref={setPane} className={clsx(styles.view, !branches && styles.noBranches)} style={columnStyle}>
|
||||
{!visible && (
|
||||
<div className={styles.banner}>
|
||||
<T>Coverage is hidden in editors and the project view.</T>
|
||||
@@ -115,18 +137,29 @@ export function CoverageView() {
|
||||
)}
|
||||
<div className={styles.header} role="row">
|
||||
{columns.map((c) => (
|
||||
<button
|
||||
key={c.key}
|
||||
type="button"
|
||||
role="columnheader"
|
||||
aria-sort={sort.key === c.key ? (sort.ascending ? "ascending" : "descending") : "none"}
|
||||
className={styles.headerCell}
|
||||
title={tx(c.label)}
|
||||
onClick={() => toggleSort(c.key)}
|
||||
>
|
||||
<span className={styles.label}>{tx(c.label)}</span>
|
||||
{sort.key === c.key && <Icon name={sort.ascending ? "chevron-up" : "chevron-down"} size={12} />}
|
||||
</button>
|
||||
<div className={styles.heading} key={c.key}>
|
||||
<button
|
||||
type="button"
|
||||
role="columnheader"
|
||||
aria-sort={sort.key === c.key ? (sort.ascending ? "ascending" : "descending") : "none"}
|
||||
className={styles.headerCell}
|
||||
title={tx(c.label)}
|
||||
onClick={() => toggleSort(c.key)}
|
||||
>
|
||||
<span className={styles.label}>{tx(c.label)}</span>
|
||||
{sort.key === c.key && <Icon name={sort.ascending ? "chevron-up" : "chevron-down"} size={12} />}
|
||||
</button>
|
||||
{c.key !== "name" && paneWidth > 0 && (
|
||||
<ColumnDivider
|
||||
title={c.label}
|
||||
width={widths[c.key]}
|
||||
min={min}
|
||||
max={c.key === "lines" ? budget - widths.branches : statsWidth - min}
|
||||
onResize={c.key === "lines" ? resizeLines : resizeBranches}
|
||||
onReset={() => setPreferred(branches ? {} : { branches: preferred.branches })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Tree<CoverageNode>
|
||||
@@ -152,8 +185,8 @@ export function CoverageView() {
|
||||
{n.name}
|
||||
</span>
|
||||
</span>
|
||||
<Metric covered={n.linesCovered} total={n.linesTotal} />
|
||||
{branches && <Metric covered={n.branchesCovered} total={n.branchesTotal} />}
|
||||
<Metric covered={n.linesCovered} total={n.linesTotal} compact={widths.lines < 92} />
|
||||
{branches && <Metric covered={n.branchesCovered} total={n.branchesTotal} compact={widths.branches < 92} />}
|
||||
</span>
|
||||
)}
|
||||
empty={<EmptyState title="The report covers no files" />}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
type PreferredWidths = Partial<Record<"lines" | "branches", number>>;
|
||||
|
||||
const KEY = "openidea.coverage.columns";
|
||||
|
||||
export function readCoverageWidths(): PreferredWidths {
|
||||
try {
|
||||
const widths = JSON.parse(localStorage.getItem(KEY) ?? "null");
|
||||
const valid = (n: unknown) => (typeof n === "number" && Number.isFinite(n) && n > 0 ? n : undefined);
|
||||
return { lines: valid(widths?.lines), branches: valid(widths?.branches) };
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function saveCoverageWidths(widths: PreferredWidths) {
|
||||
try {
|
||||
localStorage.setItem(KEY, JSON.stringify(widths));
|
||||
} catch {
|
||||
/* Storage may be unavailable. */
|
||||
}
|
||||
}
|
||||
|
||||
export function coverageColumns(pane: number, hasBranches: boolean, preferred: PreferredWidths) {
|
||||
const min = Math.min(52, Math.floor(pane / 5));
|
||||
const count = hasBranches ? 2 : 1;
|
||||
// Reserve space for the tree label, its icons and indentation, and the table gutters.
|
||||
const budget = Math.max(count * min, pane - 132);
|
||||
const auto = Math.round(pane < 360 ? Math.min(pane * 0.23, 65) : Math.min(pane * 0.29, 128));
|
||||
const lines = Math.min(budget, Math.max(min, preferred.lines ?? auto));
|
||||
const branches = hasBranches ? Math.min(budget, Math.max(min, preferred.branches ?? auto)) : 0;
|
||||
if (lines + branches <= budget) return { min, budget, widths: { lines, branches } };
|
||||
|
||||
// Fit saved widths proportionally on a smaller dock without changing the saved layout.
|
||||
const room = budget - min * count;
|
||||
const fittedLines = min + Math.round(((lines - min) / (lines + branches - min * count)) * room);
|
||||
return { min, budget, widths: { lines: fittedLines, branches: budget - fittedLines } };
|
||||
}
|
||||
@@ -241,7 +241,8 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
|
||||
const filter = screen.getByRole("textbox", { name: "筛选类" });
|
||||
expect(filter.getAttribute("placeholder")).toBe("筛选类");
|
||||
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
|
||||
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
|
||||
} finally {
|
||||
await setLocale("en");
|
||||
}
|
||||
@@ -299,10 +300,15 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByText("Cache$Entry")).toBeTruthy();
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
|
||||
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
|
||||
const options = screen.getByRole("button", { name: "View Options" });
|
||||
fireEvent.click(options);
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
|
||||
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("order", order, session), { pos: 0, timeout: 4000 });
|
||||
showHint(view, () => valueHint(view, "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("order", order, session, 400, { pin }), { pos: 0 });
|
||||
showHint(view, () => valueHint(view, "order", order, session, 400, { pin }), { pos: 0 });
|
||||
expand();
|
||||
expect(pin).toHaveBeenCalled();
|
||||
expect(document.querySelector(".tree")).toBeNull();
|
||||
|
||||
@@ -169,13 +169,25 @@
|
||||
|
||||
/* Data Views › Show value tooltip on mouse hover. */
|
||||
.valueTooltip {
|
||||
max-width: 520px;
|
||||
padding: 4px 8px;
|
||||
font-family: var(--font-mono);
|
||||
font-weight: var(--fw-code);
|
||||
font-size: var(--fs-code);
|
||||
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;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.valueGlyph {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
margin-top: 1px;
|
||||
}
|
||||
.valueTooltipTree {
|
||||
display: flex;
|
||||
@@ -194,19 +206,22 @@
|
||||
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;
|
||||
margin-right: 4px;
|
||||
flex: none;
|
||||
margin-top: 1px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: var(--radius-small);
|
||||
background: transparent;
|
||||
color: var(--fg-muted);
|
||||
vertical-align: -3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.valueExpand:hover {
|
||||
|
||||
@@ -49,7 +49,7 @@ class InlineValues extends WidgetType {
|
||||
e.stopPropagation();
|
||||
const session = activeSession();
|
||||
if (!session || session.status !== "paused") return;
|
||||
showHint(view, () => valueHint(part.name, part.variable, session.id, null), {
|
||||
showHint(view, () => valueHint(view, 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(part.name, part.variable, session.id, null), {
|
||||
showHint(view, () => valueHint(view, part.name, part.variable, session.id, null), {
|
||||
pos: view.posAtDOM(show),
|
||||
timeout: 60_000,
|
||||
});
|
||||
|
||||
@@ -13,6 +13,7 @@ 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";
|
||||
|
||||
@@ -96,6 +97,7 @@ 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,
|
||||
@@ -104,15 +106,21 @@ 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: () => tree?.unmount() };
|
||||
return { dom, destroy };
|
||||
}
|
||||
if (value.variablesReference > 0) {
|
||||
// IDEA's value hint: the "+" expands the object into a variables tree in place.
|
||||
@@ -131,6 +139,8 @@ 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} = `;
|
||||
@@ -143,11 +153,33 @@ export function valueHint(
|
||||
span.textContent = text;
|
||||
return span;
|
||||
};
|
||||
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() };
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
||||
export function showQuickValue(
|
||||
@@ -158,7 +190,7 @@ export function showQuickValue(
|
||||
session: DebugSessionId,
|
||||
) {
|
||||
if (value.variablesReference > 0) showValueTree(view, pos, expression, value, session);
|
||||
else showHint(view, () => valueHint(expression, value, session), { pos, timeout: 60_000 });
|
||||
else showHint(view, () => valueHint(view, expression, value, session), { pos, timeout: 60_000 });
|
||||
}
|
||||
|
||||
export function valueTooltip(): Extension {
|
||||
@@ -185,7 +217,7 @@ export function valueTooltip(): Extension {
|
||||
end: expr.to,
|
||||
above: true,
|
||||
create: (view) =>
|
||||
valueHint(expr.text, value, session.id, 400, {
|
||||
valueHint(view, 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.
|
||||
@@ -208,21 +240,7 @@ 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(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);
|
||||
const hint = valueHint(view, expression, value, session, 400, { expanded: true });
|
||||
// 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;
|
||||
@@ -233,8 +251,6 @@ function pinnedTree(view: EditorView, expression: string, value: Variable, sessi
|
||||
return {
|
||||
dom: hint.dom,
|
||||
destroy: () => {
|
||||
resize.disconnect();
|
||||
cancelAnimationFrame(resizeFrame);
|
||||
unsubscribe();
|
||||
hint.destroy();
|
||||
},
|
||||
@@ -287,7 +303,10 @@ export function selectionValueTooltip(): Extension {
|
||||
}
|
||||
// The selection moved on while evaluating.
|
||||
if (seq !== this.seq) return;
|
||||
showHint(this.view, () => valueHint(expr.text, value, session.id), { pos: expr.from, timeout: 60_000 });
|
||||
showHint(this.view, () => valueHint(this.view, expr.text, value, session.id), {
|
||||
pos: expr.from,
|
||||
timeout: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
}
|
||||
|
||||
.filter {
|
||||
flex: 0 1 240px;
|
||||
min-width: 80px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.banner,
|
||||
|
||||
@@ -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 } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
|
||||
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
|
||||
@@ -112,6 +112,8 @@ 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";
|
||||
@@ -161,17 +163,37 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
disabled={entry?.loading || !canRefresh}
|
||||
/>
|
||||
<HeapCaptureButton session={session} />
|
||||
<Input
|
||||
<SearchField
|
||||
className={styles.filter}
|
||||
value={query.filter}
|
||||
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
|
||||
onChange={(filter) => setMemoryQuery(id, { filter })}
|
||||
placeholder="Filter classes"
|
||||
aria-label="Filter classes"
|
||||
/>
|
||||
<Checkbox
|
||||
checked={query.changedOnly}
|
||||
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
|
||||
label="Changed only"
|
||||
<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 }),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{backend && (
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 16px;
|
||||
color: var(--fg-faint);
|
||||
@@ -21,12 +17,53 @@
|
||||
}
|
||||
|
||||
/* breakpoint popover */
|
||||
.bpEditor {
|
||||
width: 340px;
|
||||
padding: 10px 12px;
|
||||
.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 {
|
||||
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 {
|
||||
@@ -86,21 +123,27 @@
|
||||
}
|
||||
|
||||
.bpFooter {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
margin-top: 2px;
|
||||
flex-wrap: wrap;
|
||||
border-block-start: 1px solid var(--border-popup);
|
||||
}
|
||||
|
||||
.link {
|
||||
.bpFooterButtons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
.bpMore {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
color: var(--accent);
|
||||
font-size: var(--fs-ui);
|
||||
cursor: pointer;
|
||||
}
|
||||
.link:hover {
|
||||
.bpMore:hover {
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type CSSProperties,
|
||||
type KeyboardEvent,
|
||||
type MutableRefObject,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
@@ -137,6 +138,62 @@ 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,
|
||||
@@ -155,49 +212,25 @@ function BreakpointEditor({
|
||||
};
|
||||
|
||||
return (
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeBreakpoint(path, bp.id)}
|
||||
title={
|
||||
<>
|
||||
<span className={styles.bpDot} data-look={bp.enabled ? "on" : "off"} aria-hidden />
|
||||
<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>
|
||||
<BreakpointLocation path={path} line={bp.line} />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<BreakpointFields
|
||||
path={path}
|
||||
bp={bp}
|
||||
focus={focusLog ? "log" : "condition"}
|
||||
onEnter={close}
|
||||
commitRef={commitText}
|
||||
/>
|
||||
</BreakpointPropertiesPopup>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -365,66 +398,46 @@ function SpecialEditor({ bp, at }: { bp: SpecialBreakpoint; at: { x: number; y:
|
||||
closeBreakpointPopover();
|
||||
};
|
||||
return (
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeSpecial(bp.id)}
|
||||
title={
|
||||
<>
|
||||
<Icon name={bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<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 className={styles.bpFile} title={specialTitle(bp)}>
|
||||
{specialTitle(bp)}
|
||||
</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>
|
||||
<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>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.renameForm {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
padding: 14px;
|
||||
padding: var(--space-3) var(--space-4);
|
||||
}
|
||||
|
||||
.renameName {
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.renameOptions {
|
||||
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%;
|
||||
}
|
||||
|
||||
.refactorForm {
|
||||
|
||||
@@ -143,7 +143,7 @@ function Options({
|
||||
disabled: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className={styles.options}>
|
||||
<div className={move ? styles.options : styles.renameOptions}>
|
||||
<Checkbox
|
||||
label="Search for references"
|
||||
checked={value.references}
|
||||
@@ -223,31 +223,33 @@ function RenameDialog({ request }: { request: Extract<FileRefactorRequest, { kin
|
||||
]}
|
||||
>
|
||||
<form
|
||||
className={styles.form}
|
||||
className={styles.renameForm}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
submit();
|
||||
}}
|
||||
>
|
||||
<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 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>
|
||||
<Options value={options} onChange={setOptions} move={false} disabled={busy} />
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
import { useMemo, useState, type KeyboardEvent } from "react";
|
||||
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import { HighlightedText, Icon, List, Popup, SearchField, fuzzyMatch, listNavigate, T, type PopupAnchor } from "@/ui";
|
||||
import {
|
||||
HighlightedText,
|
||||
Icon,
|
||||
List,
|
||||
Popup,
|
||||
SearchField,
|
||||
firstSelectable,
|
||||
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";
|
||||
@@ -64,12 +75,11 @@ export function AddConfigPopup({
|
||||
const [query, setQuery] = useState("");
|
||||
const rows = useMemo(() => typeRows(runConfigTypes(types), query), [types, query]);
|
||||
const isSection = (r: TypeRow) => r.kind === "group";
|
||||
const first = Math.max(
|
||||
0,
|
||||
rows.findIndex((r) => r.kind === "type"),
|
||||
);
|
||||
const [active, setActive] = useState(first);
|
||||
const [active, setActive] = useState(-1);
|
||||
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;
|
||||
@@ -80,10 +90,11 @@ export function AddConfigPopup({
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
pick(rows[clamped]);
|
||||
pick(rows[selected]);
|
||||
return;
|
||||
}
|
||||
const next = listNavigate(e.key, { items: rows, active: clamped, isSection, wrap: true });
|
||||
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 });
|
||||
if (next !== null) {
|
||||
e.preventDefault();
|
||||
setActive(next);
|
||||
@@ -97,7 +108,7 @@ export function AddConfigPopup({
|
||||
onClose={onClose}
|
||||
placement="bottom-start"
|
||||
aria-label="Add New Configuration"
|
||||
className={styles.chooser}
|
||||
className={clsx(styles.chooser, styles.typeChooser)}
|
||||
trapFocus
|
||||
>
|
||||
<div className={styles.chooserCaption}>
|
||||
@@ -108,7 +119,7 @@ export function AddConfigPopup({
|
||||
value={query}
|
||||
onChange={(v) => {
|
||||
setQuery(v);
|
||||
setActive(0);
|
||||
setActive(-1);
|
||||
}}
|
||||
placeholder="Search types"
|
||||
aria-label="Search configuration types"
|
||||
@@ -117,7 +128,7 @@ export function AddConfigPopup({
|
||||
variant="bare"
|
||||
/>
|
||||
</div>
|
||||
<div style={{ height: Math.max(rowHeight, Math.min(rows.length * rowHeight, 14 * rowHeight)) }}>
|
||||
<div ref={viewport} className={styles.chooserViewport} style={{ height }}>
|
||||
<List<TypeRow>
|
||||
aria-label="Configuration types"
|
||||
className={styles.chooserList}
|
||||
@@ -125,7 +136,7 @@ export function AddConfigPopup({
|
||||
getKey={(r) => r.key}
|
||||
isSection={isSection}
|
||||
renderSection={(r) => (r.kind === "group" ? r.label : null)}
|
||||
activeIndex={rows[clamped]?.kind === "type" ? clamped : first}
|
||||
activeIndex={selected}
|
||||
onActiveChange={setActive}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
@@ -139,7 +150,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={13} className={styles.chooserIcon} />
|
||||
<Icon name={r.type.icon} size={16} className={styles.chooserIcon} />
|
||||
<span className={styles.chooserName}>
|
||||
{r.indices?.length ? <HighlightedText text={r.type.label} indices={r.indices} /> : r.type.label}
|
||||
</span>
|
||||
|
||||
+118
-57
@@ -6,7 +6,16 @@
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { isJvmApplication, parseJavaArgs } from "@/platform/javaLaunch";
|
||||
import { useRunTargets } from "@/platform/pluginRunTargets";
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode, type RefObject } from "react";
|
||||
import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type KeyboardEvent,
|
||||
type MouseEvent,
|
||||
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";
|
||||
@@ -54,6 +63,16 @@ 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
|
||||
@@ -332,7 +351,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(false);
|
||||
const [taskMenu, setTaskMenu] = useState<"add" | { index: number; anchor: HTMLButtonElement } | null>(null);
|
||||
const modifyRef = useRef<HTMLButtonElement>(null);
|
||||
const taskRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
@@ -406,23 +425,23 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
run: () => addTask("run", c.id),
|
||||
})),
|
||||
},
|
||||
{ label: TASK_LABELS.build, icon: "build-project", run: () => addTask("build") },
|
||||
{ label: TASK_LABELS.build, icon: TASK_ICONS.build, run: () => addTask("build") },
|
||||
{
|
||||
label: TASK_LABELS.buildModule,
|
||||
icon: "build-project",
|
||||
icon: TASK_ICONS.buildModule,
|
||||
disabled: config.module == null,
|
||||
run: () => addTask("buildModule", config.module ?? ""),
|
||||
},
|
||||
{ label: TASK_LABELS.buildArtifacts, icon: "build-rebuild", run: () => addTask("buildArtifacts") },
|
||||
{ label: TASK_LABELS.buildArtifacts, icon: TASK_ICONS.buildArtifacts, run: () => addTask("buildArtifacts") },
|
||||
...(config.kind === "dotnet"
|
||||
? [{ label: TASK_LABELS.dotnetBuild, icon: "build-project", run: () => addTask("dotnetBuild") }]
|
||||
? [{ label: TASK_LABELS.dotnetBuild, icon: TASK_ICONS.dotnetBuild, 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: "terminal", run: () => addTask("command") },
|
||||
{ label: TASK_LABELS.command, icon: TASK_ICONS.command, run: () => addTask("command") },
|
||||
{
|
||||
label: TASK_LABELS.toolWindow,
|
||||
submenu: [...toolWindows.values()]
|
||||
@@ -442,6 +461,7 @@ 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" },
|
||||
@@ -763,62 +783,103 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
|
||||
{isShown("beforeLaunch") && (
|
||||
<Field label="Before launch" error={errors.beforeLaunch} top>
|
||||
<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}>
|
||||
<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>
|
||||
)}
|
||||
<IconButton
|
||||
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"
|
||||
icon="close"
|
||||
size="small"
|
||||
iconSize={12}
|
||||
title="Remove Task"
|
||||
onClick={() => setTasks(tasks.filter((_, j) => j !== i))}
|
||||
/>
|
||||
</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>
|
||||
);
|
||||
})}
|
||||
<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)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { useState } from "react";
|
||||
import { useRef, useState, type RefObject } from "react";
|
||||
import clsx from "clsx";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { Dialog, IconButton } from "@/ui";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { Button, IconButton, Popup } from "@/ui";
|
||||
import styles from "./Run.module.css";
|
||||
|
||||
/**
|
||||
@@ -25,9 +26,10 @@ export function ExpandableTextarea({
|
||||
onChange: (value: string) => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const fieldRef = useRef<HTMLDivElement>(null);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
return (
|
||||
<div className={styles.textareaWithButton}>
|
||||
<div ref={fieldRef} className={styles.textareaWithButton}>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
|
||||
aria-label={tx(label)}
|
||||
@@ -43,58 +45,86 @@ export function ExpandableTextarea({
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<IconButton icon="expand-all" size="small" iconSize={14} title="Expand (⇧⏎)" onClick={() => setExpanded(true)} />
|
||||
<IconButton
|
||||
icon="expand-all"
|
||||
size="small"
|
||||
iconSize={14}
|
||||
title="Expand (⇧⏎)"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={expanded}
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
/>
|
||||
{expanded && (
|
||||
<ExpandedTextDialog label={label} value={value} onOk={onChange} onClose={() => setExpanded(false)} />
|
||||
<ExpandedTextPopup
|
||||
anchor={fieldRef}
|
||||
label={tx(label)}
|
||||
value={value}
|
||||
onOk={onChange}
|
||||
onClose={() => setExpanded(false)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ExpandedTextDialog({
|
||||
function ExpandedTextPopup({
|
||||
anchor,
|
||||
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 (
|
||||
<Dialog
|
||||
<Popup
|
||||
open
|
||||
title={tx(label)}
|
||||
anchor={anchor}
|
||||
aria-label={label}
|
||||
className={styles.expandedEditor}
|
||||
onClose={onClose}
|
||||
width={720}
|
||||
trapFocus
|
||||
matchWidth
|
||||
closeOnDeactivate={false}
|
||||
resizable="both"
|
||||
minWidth={360}
|
||||
minHeight={220}
|
||||
buttons={[
|
||||
{
|
||||
label: "OK",
|
||||
role: "default",
|
||||
onClick: () => {
|
||||
if (text !== value) onOk(text);
|
||||
onClose();
|
||||
},
|
||||
},
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
minWidth={240}
|
||||
minHeight={160}
|
||||
>
|
||||
<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>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
@@ -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, defaultExportPath, loadExportOptions } from "./ExportTestResultsDialog";
|
||||
import { ExportTestResultsDialog, defaultExportName, loadExportOptions } from "./ExportTestResultsDialog";
|
||||
import { TestResults } from "./testing";
|
||||
|
||||
const actions = vi.hoisted(() => ({ executeAction: vi.fn(async () => {}) }));
|
||||
@@ -56,13 +56,15 @@ function open(onClose = vi.fn()) {
|
||||
return onClose;
|
||||
}
|
||||
|
||||
const file = () => screen.getByLabelText("Output file");
|
||||
const file = () => screen.getByLabelText("File name");
|
||||
const folder = () => screen.getByLabelText("Folder");
|
||||
const press = (name: string) => fireEvent.click(screen.getByRole("button", { name }));
|
||||
|
||||
describe("ExportTestResultsDialog", () => {
|
||||
it("writes an HTML report to the project folder under IDEA's name and opens it in the browser", async () => {
|
||||
it("writes an HTML report to the project folder and opens it in the browser", async () => {
|
||||
const onClose = open();
|
||||
expect(file()).toHaveValue("/work/app/Test Results - go test _calc.html");
|
||||
expect(file()).toHaveValue("Test Results - go test _calc.html");
|
||||
expect(folder()).toHaveValue("/work/app/");
|
||||
expect(screen.getByRole("radio", { name: "HTML" })).toBeChecked();
|
||||
press("OK");
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled());
|
||||
@@ -92,7 +94,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("/work/app/Test Results - go test _calc.xml");
|
||||
expect(file()).toHaveValue("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");
|
||||
@@ -143,18 +145,36 @@ describe("ExportTestResultsDialog", () => {
|
||||
});
|
||||
|
||||
it("doesn't ask again for a file the save dialog already confirmed", async () => {
|
||||
onDisk["/tmp/picked.html"] = "file";
|
||||
dialog.save.mockResolvedValueOnce("/tmp/picked.html");
|
||||
const path = "C:\\reports\\picked.html";
|
||||
onDisk[path] = "file";
|
||||
dialog.save.mockResolvedValueOnce(path);
|
||||
const onClose = open();
|
||||
press("Browse…");
|
||||
await waitFor(() => expect(file()).toHaveValue("/tmp/picked.html"));
|
||||
await waitFor(() => expect(file()).toHaveValue("picked.html"));
|
||||
expect(folder()).toHaveValue("C:\\reports\\");
|
||||
expect(dialog.save).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ filters: [{ name: "HTML", extensions: ["html"] }] }),
|
||||
expect.objectContaining({
|
||||
defaultPath: "/work/app/Test Results - go test _calc.html",
|
||||
filters: [{ name: "HTML", extensions: ["html"] }],
|
||||
}),
|
||||
);
|
||||
press("OK");
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled());
|
||||
expect(messages.confirm).not.toHaveBeenCalled();
|
||||
expect(written.map((w) => w.path)).toEqual(["/tmp/picked.html"]);
|
||||
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);
|
||||
});
|
||||
|
||||
it("reports a directory or a failed write and stays open", async () => {
|
||||
@@ -187,15 +207,11 @@ describe("ExportTestResultsDialog", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("defaultExportPath", () => {
|
||||
describe("defaultExportName", () => {
|
||||
it("replaces characters file systems refuse in the configuration's name", () => {
|
||||
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");
|
||||
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");
|
||||
});
|
||||
});
|
||||
@@ -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 { useState } from "react";
|
||||
import { useId, useState } from "react";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
@@ -38,13 +38,35 @@ function saveExportOptions(o: ExportOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
/** Runs of dots and characters file systems refuse become one `_`. */
|
||||
export function defaultExportName(name: string, format: TestExportFormat): string {
|
||||
const safe = name.replace(/[/\\:*?"<>|.]+/g, "_").replace(/^[\s_]+|[\s_]+$/g, "");
|
||||
return `${dir.replace(/[\\/]+$/, "")}/Test Results - ${safe || "Tests"}.${format}`;
|
||||
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}`;
|
||||
}
|
||||
|
||||
async function exists(path: string): Promise<"file" | "dir" | null> {
|
||||
@@ -111,44 +133,47 @@ export function ExportTestResultsDialog({
|
||||
cwd: string;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const fileNameId = useId();
|
||||
const folderId = useId();
|
||||
const [options, setOptions] = useState(loadExportOptions);
|
||||
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 [destination, setDestination] = useState<Destination>(() => ({
|
||||
folder: cwd,
|
||||
fileName: defaultExportName(name, options.format),
|
||||
}));
|
||||
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) setPath((p) => p.replace(/\.(html|xml)$/i, `.${next.format}`));
|
||||
if (next.format) {
|
||||
const nextName = fileName.replace(/\.(html|xml)$/i, `.${next.format}`);
|
||||
if (nextName !== fileName) setDestination({ folder, fileName: nextName });
|
||||
}
|
||||
};
|
||||
|
||||
const browse = async () => {
|
||||
try {
|
||||
const { save } = await import("@/platform/dialog");
|
||||
const chosen = await save({
|
||||
defaultPath: path,
|
||||
defaultPath: target || folder || cwd,
|
||||
filters: [{ name: html ? "HTML" : "XML", extensions: [options.format] }],
|
||||
});
|
||||
if (chosen) {
|
||||
setPath(chosen);
|
||||
setPicked(chosen);
|
||||
}
|
||||
if (chosen) setDestination(destinationFromPicker(chosen));
|
||||
} catch {
|
||||
// No dialog (tests): keep typing the path.
|
||||
}
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
const raw = path.trim();
|
||||
if (!raw) return;
|
||||
const target = isAbsolutePath(raw) ? raw : `${cwd.replace(/[\\/]+$/, "")}/${raw}`;
|
||||
if (!target) return;
|
||||
setBusy(true);
|
||||
const text = exportTestResults(options.format, results, { name, cwd, date: new Date() });
|
||||
const ok = await writeTestReport(target, text, picked === raw);
|
||||
const ok = await writeTestReport(target, text, pickedPath !== undefined);
|
||||
setBusy(false);
|
||||
if (!ok) return;
|
||||
onClose();
|
||||
@@ -167,29 +192,46 @@ export function ExportTestResultsDialog({
|
||||
open
|
||||
title="Export Test Results"
|
||||
onClose={onClose}
|
||||
width={520}
|
||||
width={500}
|
||||
buttons={[
|
||||
{ label: "OK", role: "default", disabled: busy || !path.trim(), onClick: () => void run() },
|
||||
{ label: "OK", role: "default", disabled: busy || !target, onClick: () => void run() },
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.dialogBody}>
|
||||
<div className={styles.exportFormats} role="radiogroup" aria-label="Export format">
|
||||
<span>
|
||||
<div className={styles.exportReport}>
|
||||
<fieldset className={styles.exportFormats} role="radiogroup">
|
||||
<legend>
|
||||
<T>Export format:</T>
|
||||
</span>
|
||||
</legend>
|
||||
<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" })} />
|
||||
</div>
|
||||
<label className={styles.exportField}>
|
||||
<span>
|
||||
<T>Output file:</T>
|
||||
</span>
|
||||
</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 className={styles.inputWithButton}>
|
||||
<Input mono aria-label="Output file" value={path} onChange={(e) => setPath(e.target.value)} />
|
||||
<Input
|
||||
id={folderId}
|
||||
value={folder}
|
||||
onChange={(e) => setDestination({ folder: e.target.value, fileName })}
|
||||
/>
|
||||
<IconButton icon="folder" title="Browse…" onClick={() => void browse()} />
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
<Checkbox
|
||||
checked={html && options.openInBrowser}
|
||||
disabled={!html}
|
||||
|
||||
+107
-17
@@ -560,6 +560,17 @@
|
||||
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;
|
||||
@@ -911,28 +922,44 @@
|
||||
outline: none;
|
||||
}
|
||||
.textareaWithButton {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-1-5);
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
}
|
||||
.textareaWithButton > textarea {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding-inline-end: calc(var(--space-3) + var(--space-4));
|
||||
}
|
||||
.textareaWithButton > button {
|
||||
flex-shrink: 0;
|
||||
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);
|
||||
}
|
||||
/* One visual line per line of text: a long argument scrolls instead of wrapping. */
|
||||
.expandedTextarea {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 160px;
|
||||
box-sizing: border-box;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
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);
|
||||
}
|
||||
@@ -958,10 +985,43 @@
|
||||
.taskRow > :first-child {
|
||||
min-width: 0;
|
||||
}
|
||||
.taskActions {
|
||||
.beforeLaunchTasks {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.taskTag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
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);
|
||||
}
|
||||
.taskLabel {
|
||||
overflow: hidden;
|
||||
@@ -1134,18 +1194,48 @@
|
||||
gap: var(--space-2);
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.exportFormats {
|
||||
.exportReport {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4) var(--space-1);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.exportField {
|
||||
|
||||
.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;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
justify-items: start;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.exportOutput {
|
||||
display: grid;
|
||||
grid-template-columns: max-content 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);
|
||||
|
||||
@@ -375,7 +375,8 @@ 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("Output file")).toHaveValue("/p/Test Results - calc tests.html");
|
||||
expect(screen.getByLabelText("File name")).toHaveValue("Test Results - calc tests.html");
|
||||
expect(screen.getByLabelText("Folder")).toHaveValue("/p");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
expect(screen.queryByRole("dialog", { name: "Export Test Results" })).toBeNull();
|
||||
unmount();
|
||||
|
||||
@@ -262,6 +262,7 @@ 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,
|
||||
|
||||
@@ -82,6 +82,7 @@ async function profileMenu(entry: ScriptEntry, path: string): Promise<MenuItem[]
|
||||
return [
|
||||
{
|
||||
label: tx`Run '${config.name}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "run",
|
||||
shortcut: shortcutLabel("run.runContext"),
|
||||
run: () =>
|
||||
@@ -91,6 +92,7 @@ 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),
|
||||
|
||||
@@ -283,6 +283,7 @@ export async function scriptMenuItems(entry: ScriptEntry, path: string, content:
|
||||
return [
|
||||
{
|
||||
label: tx`Run '${label}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "run",
|
||||
shortcut: shortcutLabel("run.runContext"),
|
||||
run: () =>
|
||||
@@ -292,6 +293,7 @@ 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),
|
||||
|
||||
@@ -109,11 +109,18 @@ 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}'`, icon: "run", shortcut: shortcutLabel("run.runContext"), ...pick(false) } as MenuItem,
|
||||
{
|
||||
label: tx`Run '${name}'`,
|
||||
preserveLabelEnd: true,
|
||||
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: 3, files: 1 }, "foo", "bar")).toBe(
|
||||
"Replace 3 occurrences of 'foo' with 'bar' in 1 file?",
|
||||
);
|
||||
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(summaryText({ files: 2, replacements: 1, failed: 0, cancelled: false, elapsedMs: 3 })).toBe(
|
||||
"Replaced 1 occurrence in 2 files",
|
||||
);
|
||||
|
||||
@@ -248,6 +248,20 @@
|
||||
.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,8 +934,11 @@ function ResultRow({
|
||||
<span className={styles.main}>
|
||||
<CodeText path={row.path} text={row.text} indices={row.indices} />
|
||||
</span>
|
||||
<span className={clsx(styles.right, active && styles.rightActive)}>
|
||||
<span className={clsx(repeat && !active && styles.repeat)}>{basename(row.rel)}</span> {row.line + 1}
|
||||
<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>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -201,23 +201,32 @@
|
||||
.previewHeader {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
height: 36px;
|
||||
padding: 0 20px;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1);
|
||||
padding: 10px 20px var(--space-1-5);
|
||||
border-top: 1px solid var(--border-popup);
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-ui);
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.previewPath {
|
||||
.previewDirectory {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
}
|
||||
.previewName,
|
||||
.previewSegment {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.previewName,
|
||||
.previewParent {
|
||||
flex: none;
|
||||
}
|
||||
.previewName {
|
||||
color: var(--fg-strong);
|
||||
margin-right: 8px;
|
||||
}
|
||||
.previewBox {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SearchHistoryMenu } from "@/ui/SearchHistoryMenu";
|
||||
import {
|
||||
useEffect,
|
||||
useId,
|
||||
@@ -39,14 +40,12 @@ 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,
|
||||
@@ -74,7 +73,6 @@ import {
|
||||
customScopeName,
|
||||
customScopeValue,
|
||||
describeQuery,
|
||||
findHistory,
|
||||
hideFindPopup,
|
||||
recentMasks,
|
||||
rememberFindString,
|
||||
@@ -284,6 +282,8 @@ 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,22 +346,11 @@ function FindInFilesDialog() {
|
||||
void replaceAll(usages);
|
||||
return;
|
||||
}
|
||||
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>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
const ok = await confirmReplacement({
|
||||
counts: allInScope ? null : counts,
|
||||
pattern: s.pattern,
|
||||
replacement: s.replacement || "",
|
||||
hasExclusions: marks.excluded.size > 0,
|
||||
});
|
||||
if (ok) void replaceAll(usages, allInScope);
|
||||
};
|
||||
@@ -563,19 +552,6 @@ 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,
|
||||
@@ -890,16 +866,21 @@ function FindInFilesDialog() {
|
||||
</SplitPanel>
|
||||
<SplitHandle hairline={false} />
|
||||
<SplitPanel id="preview" minSize={96}>
|
||||
<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>
|
||||
{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.previewBox}>
|
||||
{!stale && previewMode && s.replace && selected ? (
|
||||
<ReplaceDiffPreview
|
||||
@@ -974,12 +955,10 @@ function FindInFilesDialog() {
|
||||
placement="bottom-end"
|
||||
onClose={() => setMaskMenu(false)}
|
||||
/>
|
||||
<Menu
|
||||
open={historyMenu !== null}
|
||||
<SearchHistoryMenu
|
||||
kind={historyMenu}
|
||||
anchor={historyMenu === "replace" ? replaceBoxRef : patternBoxRef}
|
||||
items={historyMenu ? historyItems(historyMenu) : []}
|
||||
placement="bottom-start"
|
||||
aria-label="Recent searches"
|
||||
onSelect={(value) => set(historyMenu === "replace" ? { replacement: value } : { pattern: value })}
|
||||
onClose={() => setHistoryMenu(null)}
|
||||
/>
|
||||
<Menu
|
||||
|
||||
@@ -23,14 +23,12 @@ 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,
|
||||
@@ -369,22 +367,11 @@ 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 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>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
const ok = await confirmReplacement({
|
||||
counts: allInScope ? null : countUsages(allPending),
|
||||
pattern: tab.query.pattern,
|
||||
replacement: tab.replacement ?? "",
|
||||
hasExclusions: marks.excluded.size > 0,
|
||||
});
|
||||
if (ok) void replace(allPending, allInScope);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
.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);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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,26 +1,32 @@
|
||||
.body {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr;
|
||||
min-height: 300px;
|
||||
grid-template-columns: 200px minmax(0, 1fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: clamp(240px, 55vh, 360px);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
overflow: hidden;
|
||||
}
|
||||
.side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border-right: 1px solid var(--border);
|
||||
min-height: 0;
|
||||
border-inline-end: 1px solid var(--border);
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
gap: var(--space-0-5);
|
||||
padding: 4px;
|
||||
padding: var(--space-1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
padding: 4px;
|
||||
padding: var(--space-1);
|
||||
scroll-padding-block: var(--space-1);
|
||||
list-style: none;
|
||||
overflow: auto;
|
||||
}
|
||||
@@ -29,13 +35,16 @@
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: var(--h-list-row);
|
||||
padding: 0 8px;
|
||||
padding: 0 var(--space-2);
|
||||
border: 0;
|
||||
border-radius: var(--radius-row);
|
||||
background: none;
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
text-align: left;
|
||||
text-align: start;
|
||||
}
|
||||
.item > span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -47,16 +56,25 @@
|
||||
background: var(--bg-list-selected);
|
||||
}
|
||||
.empty {
|
||||
padding: 8px;
|
||||
padding: var(--space-2);
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1-5);
|
||||
padding: 10px 14px;
|
||||
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);
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.form > .error,
|
||||
.form > .empty,
|
||||
.help {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.label {
|
||||
color: var(--fg-muted);
|
||||
@@ -65,10 +83,11 @@
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-size: var(--fs-small);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.help {
|
||||
margin: 6px 0 0;
|
||||
padding-left: 16px;
|
||||
margin: 0;
|
||||
padding-inline-start: var(--space-4);
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
line-height: 1.6;
|
||||
@@ -77,3 +96,15 @@
|
||||
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,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, useState } from "react";
|
||||
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { create } from "zustand";
|
||||
import { tx, txTemplate, useTx, useTxTemplate } from "@/platform/i18n";
|
||||
@@ -88,6 +88,10 @@ 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);
|
||||
@@ -124,7 +128,7 @@ function ScopesDialog() {
|
||||
>
|
||||
<div className={styles.body}>
|
||||
<div className={styles.side}>
|
||||
<div className={styles.toolbar}>
|
||||
<div className={styles.toolbar} role="toolbar" aria-label={tr("Scopes actions")}>
|
||||
<IconButton icon="plus" title="Add Scope" size="small" onClick={add} />
|
||||
<IconButton icon="minus" title="Remove Scope" size="small" disabled={!current} onClick={remove} />
|
||||
</div>
|
||||
@@ -134,11 +138,13 @@ 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)}
|
||||
>
|
||||
{s.name || tr("Unnamed")}
|
||||
<span>{s.name || tr("Unnamed")}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -91,15 +91,10 @@ export function countUsages(usages: readonly Usage[]): ReplaceCounts {
|
||||
}
|
||||
|
||||
/** "Replace 3 occurrences in 2 files" for the confirmation dialog. */
|
||||
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.`;
|
||||
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?`;
|
||||
}
|
||||
|
||||
/** Toggles exclusion of every usage in `groups` (all excluded → include them again). */
|
||||
|
||||
@@ -42,6 +42,14 @@
|
||||
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,6 +360,7 @@ 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}
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
.presetSelect {
|
||||
flex: 1;
|
||||
}
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
.modifiedNote {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
@@ -195,53 +192,88 @@
|
||||
.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);
|
||||
}
|
||||
.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);
|
||||
.shortcutStatus {
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.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: 6px 0 0;
|
||||
padding: 0 0 0 20px;
|
||||
max-height: 120px;
|
||||
overflow: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-height: 132px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.conflictList li {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) fit-content(42%);
|
||||
align-items: start;
|
||||
gap: var(--space-2);
|
||||
height: var(--h-row);
|
||||
padding-block: var(--space-1);
|
||||
}
|
||||
.conflictAction {
|
||||
color: var(--fg);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.conflictCategory {
|
||||
.actionPath {
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.conflictsLabel {
|
||||
color: var(--fg);
|
||||
padding-top: 4px;
|
||||
.conflictBinding {
|
||||
text-align: end;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.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 { tx } from "@/platform/i18n";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
|
||||
export interface RecordShortcutDialogProps {
|
||||
@@ -39,6 +39,8 @@ 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);
|
||||
@@ -76,14 +78,23 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
|
||||
<Dialog
|
||||
open
|
||||
onClose={onCancel}
|
||||
title={mouse ? tx`Mouse Shortcut: ${action.title}` : tx`Keyboard Shortcut: ${action.title}`}
|
||||
width={440}
|
||||
title={mouse ? "Mouse Shortcut" : "Keyboard Shortcut"}
|
||||
aria-label={mouse ? tx`Mouse Shortcut: ${actionName}` : tx`Keyboard Shortcut: ${actionName}`}
|
||||
width={352}
|
||||
buttons={[
|
||||
{ label: "OK", role: "default", disabled: !binding || already, onClick: () => void ok() },
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.recordBody}>
|
||||
<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>
|
||||
{mouse ? (
|
||||
<MouseRecorder value={first} onChange={setFirst} sideButtons={!rectangularSelection} />
|
||||
) : (
|
||||
@@ -102,31 +113,23 @@ 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.conflictsLabel}>
|
||||
<T>Conflicts:</T>
|
||||
</div>
|
||||
<div className={styles.conflicts} aria-live="polite">
|
||||
<div className={styles.shortcutStatus} aria-live="polite">
|
||||
{already && (
|
||||
<span className={styles.noConflicts}>
|
||||
<span className={styles.recordHint}>
|
||||
<T>The action already has this shortcut</T>
|
||||
</span>
|
||||
)}
|
||||
{!already && binding && conflicts.length === 0 && (
|
||||
<span className={styles.noConflicts}>
|
||||
<span className={styles.recordHint}>
|
||||
<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} /> <T>is already assigned to:</T>
|
||||
<Kbd binding={binding} className={styles.conflictBinding} /> <T>is already assigned to:</T>
|
||||
</span>
|
||||
</div>
|
||||
<ConflictList conflicts={conflicts} />
|
||||
@@ -139,21 +142,26 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
|
||||
}
|
||||
|
||||
function ConflictList({ conflicts }: { conflicts: readonly Conflict[] }) {
|
||||
const tx = useTx();
|
||||
return (
|
||||
<ul className={styles.conflictList}>
|
||||
<ul className={styles.conflictList} aria-label={tx("Conflicts:")}>
|
||||
{conflicts.map((c) => (
|
||||
<li key={`${c.actionId}|${c.binding}`}>
|
||||
<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>
|
||||
<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>
|
||||
)}
|
||||
<Kbd binding={c.binding} />
|
||||
</div>
|
||||
<Kbd binding={c.binding} className={styles.conflictBinding} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -171,23 +179,26 @@ interface KeyStrokesProps {
|
||||
}
|
||||
|
||||
function KeyStrokes({ first, second, useSecond, allowsSecond, setFirst, setSecond, setUseSecond }: KeyStrokesProps) {
|
||||
const tx = useTx();
|
||||
return (
|
||||
<>
|
||||
<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}>
|
||||
<StrokeRecorder
|
||||
autoFocus
|
||||
className={styles.shortcutField}
|
||||
value={first}
|
||||
onChange={setFirst}
|
||||
aria-label={tx("First stroke")}
|
||||
/>
|
||||
<div className={styles.secondStroke}>
|
||||
<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="Second stroke"
|
||||
aria-label={tx("Second stroke")}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.recordHint}>
|
||||
|
||||
@@ -166,53 +166,64 @@ 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"),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<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 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>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -163,21 +163,33 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
padding: 4px 8px;
|
||||
padding: var(--space-1) var(--space-2);
|
||||
background: var(--bg-elev);
|
||||
border-bottom: 1px solid var(--border);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.findField {
|
||||
flex: 1;
|
||||
min-width: 160px;
|
||||
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);
|
||||
}
|
||||
.findCount {
|
||||
font-size: var(--fs-small);
|
||||
font-size: var(--fs-ui);
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--fg-subtle);
|
||||
padding: 0 6px;
|
||||
min-inline-size: 7ch;
|
||||
padding-inline: var(--space-1);
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
min-width: 56px;
|
||||
}
|
||||
.findCountNone {
|
||||
color: var(--danger);
|
||||
@@ -188,7 +200,8 @@
|
||||
top: 0;
|
||||
right: 0;
|
||||
z-index: 6;
|
||||
width: 500px;
|
||||
width: max-content;
|
||||
max-width: 100%;
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
.find[data-match-covered] {
|
||||
@@ -201,11 +214,16 @@
|
||||
|
||||
@container terminal-output (max-width: 360px) {
|
||||
.find {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) repeat(3, var(--h-control-small));
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
.findField {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.findControls {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.findClose {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ export function AmendTargetMenu({ root }: { root: string }) {
|
||||
{
|
||||
value: LAST_COMMIT,
|
||||
label: "Amend Last Commit",
|
||||
emphasized: true,
|
||||
detail: available?.latest?.summary,
|
||||
verbatimDetail: true,
|
||||
},
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
.popup {
|
||||
width: min(540px, calc(100vw - 32px));
|
||||
width: max-content;
|
||||
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-family: var(--font-mono);
|
||||
font-size: inherit;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
word-break: break-all;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@@ -30,16 +35,14 @@
|
||||
}
|
||||
|
||||
.subject {
|
||||
margin-top: 10px;
|
||||
margin-block-start: var(--space-3);
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.body {
|
||||
margin-top: 8px;
|
||||
margin-block-start: var(--space-2);
|
||||
color: var(--fg);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
@@ -147,7 +147,11 @@ function BlamePopupView({ state }: { state: BlamePopupState }) {
|
||||
onClose={() => closeBlamePopup()}
|
||||
className={styles.popup}
|
||||
>
|
||||
<div onPointerEnter={cancelBlamePopupTimers} onPointerLeave={() => scheduleCloseBlamePopup()}>
|
||||
<div
|
||||
className={styles.content}
|
||||
onPointerEnter={cancelBlamePopupTimers}
|
||||
onPointerLeave={() => scheduleCloseBlamePopup()}
|
||||
>
|
||||
<div className={styles.header}>
|
||||
<div>
|
||||
commit{" "}
|
||||
|
||||
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user