mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 23:56:05 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56cd621f72 |
No files matched your search
@@ -102,44 +102,24 @@ jobs:
|
||||
name: Rust (${{ matrix.os }})
|
||||
needs: changes
|
||||
if: needs.changes.outputs.rust == 'true'
|
||||
permissions:
|
||||
contents: read
|
||||
timeout-minutes: 60
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-22.04, windows-latest]
|
||||
# Self-hosted runners (scripts/selfhost-runner) only for trusted events, and only while the
|
||||
# SELFHOSTED_RUNNERS repository variable is 'true': runs-on cannot fall back when none is online.
|
||||
runs-on: ${{ matrix.os == 'ubuntu-22.04' && vars.SELFHOSTED_RUNNERS == 'true' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && fromJSON('["self-hosted", "openidea-selfhosted"]') || matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: pnpm/action-setup@v5
|
||||
with: { version: 11 }
|
||||
- uses: actions/setup-node@v5
|
||||
with:
|
||||
node-version: 22
|
||||
cache: ${{ runner.environment != 'self-hosted' && 'pnpm' || '' }}
|
||||
package-manager-cache: ${{ runner.environment != 'self-hosted' }}
|
||||
with: { node-version: 22, cache: pnpm }
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with: { components: "clippy, rustfmt" }
|
||||
# Self-hosted runners keep persistent local Cargo caches; GitHub-hosted runners use Actions cache
|
||||
# (only main saves it because saving takes minutes on Windows; PRs restore main's).
|
||||
# Only main saves the cache (saving takes minutes on Windows); PRs restore main's.
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
if: runner.environment != 'self-hosted'
|
||||
with:
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
# The persistent target dir makes incremental builds pay off; cap its size so it can't fill the disk.
|
||||
- name: Persistent Cargo target dir
|
||||
if: runner.environment == 'self-hosted'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "CARGO_INCREMENTAL=1" >> "$GITHUB_ENV"
|
||||
size=$(du -sm "$CARGO_TARGET_DIR" 2>/dev/null | cut -f1 || true)
|
||||
if [ "${size:-0}" -gt 40000 ]; then
|
||||
echo "$CARGO_TARGET_DIR is ${size} MB; clearing it"
|
||||
rm -rf "$CARGO_TARGET_DIR"
|
||||
fi
|
||||
- uses: taiki-e/install-action@nextest
|
||||
- name: Linux deps
|
||||
if: runner.os == 'Linux'
|
||||
|
||||
Generated
+4
-4
@@ -2361,9 +2361,9 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.3"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e"
|
||||
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
@@ -10827,9 +10827,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.9"
|
||||
version = "2.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a"
|
||||
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
|
||||
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
|
||||
assert_eq!(b.pom, canonical);
|
||||
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
|
||||
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
|
||||
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
|
||||
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
|
||||
|
||||
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
|
||||
assert_eq!(
|
||||
@@ -63,26 +63,13 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
|
||||
let gone = ops::build::build_model(&host, "main").await.unwrap();
|
||||
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
|
||||
assert!(host.project("main").unwrap().content_roots().is_empty());
|
||||
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
|
||||
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
|
||||
assert_eq!(saved(), Vec::<String>::new());
|
||||
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
|
||||
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
|
||||
host.shutdown().await;
|
||||
}
|
||||
|
||||
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
|
||||
/// the background.
|
||||
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
|
||||
for _ in 0..200 {
|
||||
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
|
||||
if ready(&roots) {
|
||||
return roots;
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
|
||||
}
|
||||
host.project("main").unwrap().lsp.jdtls_import_roots()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
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();
|
||||
});
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("gutter breakpoint keeps its location and buttons visible while editing in a short window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 410, height: 340 });
|
||||
await stubDesktop(page);
|
||||
const name = "RecalculateInternationalPaymentsAcrossMultipleRegionalSettlementCyclesAndVerifyReceiptTotals.ts";
|
||||
const path = `/dev/acme-api/${name}`;
|
||||
await page.evaluate(async (path) => {
|
||||
const contributionsModule = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ contributionsModule);
|
||||
await editorService().openFile(path);
|
||||
}, path);
|
||||
await page.locator(".cm-content").evaluate(async (editor, path) => {
|
||||
const view = (editor as HTMLElement & { cmTile: { view: EditorView } }).cmTile.view;
|
||||
const insert = Array.from({ length: 14 }, (_, i) => `const amount${i + 1} = ${i * 10};`).join("\n");
|
||||
view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert } });
|
||||
const breakpointsModule = "/src/features/debugger/breakpoints/store.ts";
|
||||
const { addBreakpoint } = await import(/* @vite-ignore */ breakpointsModule);
|
||||
window.__ipc.handlers.debug_set_breakpoints = () => [];
|
||||
addBreakpoint(path, 7, { condition: "amount8 > 50", hitCondition: ">= 3", logMessage: "amount: {amount8}" });
|
||||
}, path);
|
||||
const marker = page.locator(".cm-lineNumbers .cm-gutterElement").filter({ hasText: /^8$/ });
|
||||
const open = () => marker.click({ button: "right" });
|
||||
await open();
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Breakpoint properties" });
|
||||
const done = popup.getByRole("button", { name: "Done", exact: true });
|
||||
const condition = popup.getByLabel("Condition", { exact: true });
|
||||
await expect(condition).toBeFocused();
|
||||
await expect(done).toBeInViewport({ ratio: 1 });
|
||||
const location = popup.getByTitle(`${path}:8`, { exact: true });
|
||||
await expect(location.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(popup.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
|
||||
await condition.fill("amount8 > 60");
|
||||
const log = popup.getByRole("textbox", { name: "Evaluate and log", exact: true });
|
||||
await log.fill("paid: {amount8}");
|
||||
await expect(location).toBeInViewport({ ratio: 1 });
|
||||
await expect(done).toBeInViewport({ ratio: 1 });
|
||||
await done.click();
|
||||
await expect(popup).toBeHidden();
|
||||
|
||||
await open();
|
||||
await expect(condition).toHaveValue("amount8 > 60");
|
||||
await expect(log).toHaveValue("paid: {amount8}");
|
||||
await popup.getByRole("button", { name: /^More/ }).click();
|
||||
const dialog = page.getByRole("dialog", { name: "Breakpoints", exact: true });
|
||||
await expect(dialog.getByLabel("Condition", { exact: true })).toHaveValue("amount8 > 60");
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function showBuild(page: Page, diagnosticPath: string | null = null) {
|
||||
await page.evaluate(async (path) => {
|
||||
async function showBuild(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
const storePath = "/src/features/build/store.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { useBuildRun } = await import(/* @vite-ignore */ storePath);
|
||||
@@ -17,10 +17,10 @@ async function showBuild(page: Page, diagnosticPath: string | null = null) {
|
||||
{ kind: "out", text: "Compiling TypeScript" },
|
||||
{ kind: "err", text: "Expected a number" },
|
||||
],
|
||||
messages: [{ severity: "error", text: "Expected a number", path, range: null, code: null }],
|
||||
messages: [{ severity: "error", text: "Expected a number", path: null, range: null, code: null }],
|
||||
});
|
||||
showToolWindow("build", true);
|
||||
}, diagnosticPath);
|
||||
});
|
||||
const build = page.getByRole("region", { name: "Build", exact: true });
|
||||
await expect(build.getByRole("log", { name: "Build output" })).toBeVisible();
|
||||
return build;
|
||||
@@ -35,28 +35,6 @@ test("Build gives about two thirds of the initial split to output", async ({ wor
|
||||
expect(treeWidth / (treeWidth + consoleWidth)).toBeCloseTo(0.33, 2);
|
||||
});
|
||||
|
||||
test("Build reserves room for duration and file counts beside long directory paths", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 760, height: 680 });
|
||||
const path = "/dev/acme-api/src/services/regional-catalogs/generated/api/development/builders/catalog.ts";
|
||||
const build = await showBuild(page, path);
|
||||
const root = build.getByRole("treeitem", { name: /^Build Project/ });
|
||||
const filename = build.getByTitle(path, { exact: true }).getByText("catalog.ts", { exact: true });
|
||||
const counts = build.getByTitle(path, { exact: true }).getByText("1 error", { exact: true });
|
||||
const errorSummary = root.getByText("1 error", { exact: true });
|
||||
const elapsed = root.getByText("1 s 200 ms", { exact: true });
|
||||
await expect(elapsed).toHaveCSS("font-size", "12px");
|
||||
await expect(counts).toBeInViewport({ ratio: 1 });
|
||||
const textFits = (el: Element) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
|
||||
};
|
||||
expect(await filename.evaluate(textFits)).toBe(true);
|
||||
expect(await errorSummary.evaluate(textFits)).toBe(true);
|
||||
const [duration, row] = await Promise.all([elapsed.boundingBox(), root.boundingBox()]);
|
||||
expect(row!.x + row!.width - duration!.x - duration!.width).toBeLessThan(12);
|
||||
});
|
||||
|
||||
test("Build output and diagnostics respond to a console font change", async ({ workbench: page }) => {
|
||||
const build = await showBuild(page);
|
||||
const log = build.getByRole("log", { name: "Build output" });
|
||||
|
||||
@@ -111,7 +111,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
|
||||
});
|
||||
await expect(editor.locator(".cm-content")).toHaveCSS("font-size", zoomedSize);
|
||||
await expect(method.locator(".cm-completionLabel")).toHaveCSS("font-size", zoomedSize);
|
||||
|
||||
await page.keyboard.type("toD");
|
||||
await expect(popup.getByText("total", { exact: true })).toBeHidden();
|
||||
// Refreshing the results rebuilds the list; the hint bar must stay below it, not jump to the top.
|
||||
@@ -125,37 +124,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
|
||||
await expect(popup).toBeHidden();
|
||||
await expect(editor.locator(".cm-activeLine")).toHaveText(/^\s*order\.toDto\(\)$/);
|
||||
expect((await ipcCalls(page, "lsp_completion")).length).toBeGreaterThan(0);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/platform/actions.ts";
|
||||
await (await import(/* @vite-ignore */ path)).executeAction("editor.splitRight");
|
||||
});
|
||||
const panes = page.locator("[data-pane-id]");
|
||||
await expect(panes).toHaveCount(2);
|
||||
await page.setViewportSize({ width: 480, height: 760 });
|
||||
await panes.last().locator(".cm-content").focus();
|
||||
await page.keyboard.press("End");
|
||||
await page.keyboard.press("Enter");
|
||||
await page.keyboard.type("order.");
|
||||
await page.keyboard.press("Control+Space");
|
||||
const footer = popup.locator(".cm-lsp-completion-footer");
|
||||
await expect
|
||||
.poll(() =>
|
||||
footer.evaluate((el) => {
|
||||
const tip = el.querySelector("span")!;
|
||||
const sort = el.querySelector("button")!;
|
||||
const a = tip.getBoundingClientRect();
|
||||
const b = sort.getBoundingClientRect();
|
||||
return {
|
||||
oneRow: Math.abs(a.y + a.height / 2 - b.y - b.height / 2) <= 1,
|
||||
hintClipped: tip.scrollWidth > tip.clientWidth,
|
||||
sortFits: sort.scrollWidth <= sort.clientWidth + 1 && b.right <= el.getBoundingClientRect().right,
|
||||
};
|
||||
}),
|
||||
)
|
||||
.toEqual({ oneRow: true, hintClipped: true, sortFits: true });
|
||||
await expect(footer.getByTitle("Press ↵ to insert, ⇥ to replace")).toHaveCSS("font-size", "12px");
|
||||
await expect(footer.getByRole("button", { name: "Sort by name" })).toBeInViewport({ ratio: 1 });
|
||||
});
|
||||
|
||||
test("long completion signatures fit the editor when the workbench is narrowed", async ({ workbench: page }) => {
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("the editor color picker fits recent colors and keeps its actions visible", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 980, height: 720 });
|
||||
await page.evaluate(async () => {
|
||||
const recent = Array.from({ length: 20 }, (_, i) => `#${((i + 1) * 314241).toString(16).padStart(6, "0")}ff`);
|
||||
localStorage.setItem("openidea.colorPicker.recent.v1", JSON.stringify(recent));
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ contributions);
|
||||
await editorService().openFile("/dev/acme-api/theme.css");
|
||||
});
|
||||
const editor = page.locator(".cm-editor").first();
|
||||
const contents = editor.locator(".cm-content");
|
||||
await contents.click();
|
||||
await page.keyboard.press("Meta+a");
|
||||
await page.keyboard.insertText(".notice { color: #5a8fbd; }");
|
||||
|
||||
const swatch = editor.locator(".cm-openidea-gutter-colors").getByTitle("#5a8fbd", { exact: true });
|
||||
const picker = page.getByRole("dialog", { name: "Color picker", exact: true });
|
||||
const palette = picker.locator(".react-colorful__saturation");
|
||||
const hex = picker.getByRole("textbox", { name: "Hexadecimal", exact: true });
|
||||
const apply = picker.getByRole("button", { name: "Apply", exact: true });
|
||||
const cancel = picker.getByRole("button", { name: "Cancel", exact: true });
|
||||
const recent = picker.getByRole("group", { name: "Recent colors", exact: true }).getByRole("button");
|
||||
await swatch.click();
|
||||
await expect(hex).toHaveValue("5A8FBDFF");
|
||||
expect((await picker.boundingBox())!.width).toBeLessThanOrEqual(308);
|
||||
await expect(palette).toHaveCSS("height", "152px");
|
||||
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await hex.fill("#ff0000");
|
||||
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(picker).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 280, height: 315 });
|
||||
await swatch.click();
|
||||
await expect(recent).toHaveCount(20);
|
||||
const swatchRows = await recent.evaluateAll((elements) => {
|
||||
const rows: number[] = [];
|
||||
for (const element of elements) {
|
||||
const box = element.getBoundingClientRect();
|
||||
if (!rows.includes(box.top)) rows.push(box.top);
|
||||
const previous = element.previousElementSibling?.getBoundingClientRect();
|
||||
if (previous?.top === box.top && previous.right > box.left) throw new Error("Color swatches overlap");
|
||||
}
|
||||
return rows.length;
|
||||
});
|
||||
expect(swatchRows).toBeGreaterThan(2);
|
||||
expect(await picker.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await expect(apply).toBeInViewport({ ratio: 1 });
|
||||
await expect(cancel).toBeInViewport({ ratio: 1 });
|
||||
await hex.fill("#d27c54");
|
||||
await cancel.click();
|
||||
await expect(picker).toBeHidden();
|
||||
await expect(contents).toContainText("#5a8fbd");
|
||||
|
||||
await swatch.click();
|
||||
await hex.fill("#d27c54");
|
||||
await apply.click();
|
||||
await expect(picker).toBeHidden();
|
||||
await expect(contents).toContainText("#d27c54");
|
||||
});
|
||||
+10
-223
@@ -85,66 +85,6 @@ test("⌘K commits the checked changes with the typed message", async ({ workben
|
||||
await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden();
|
||||
});
|
||||
|
||||
test("commit options align author fields and keep the date editable in a narrow dialog", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubRepository(page);
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
const panel = page.getByRole("region", { name: "Commit", exact: true });
|
||||
await panel.getByRole("button", { name: "Commit Options", exact: true }).click();
|
||||
const popup = page.getByRole("dialog", { name: "Commit Options", exact: true });
|
||||
const author = popup.getByRole("textbox", { name: "Author", exact: true });
|
||||
const date = popup.getByLabel("Author date", { exact: true });
|
||||
const clear = popup.getByRole("button", { name: "Clear author date", exact: true });
|
||||
const name = "Regional Ledger Review <[email protected]>";
|
||||
const time = "2024-06-04T13:20:21";
|
||||
await author.fill(name);
|
||||
await date.fill(time);
|
||||
const authorBox = (await author.boundingBox())!;
|
||||
const dateBox = (await date.boundingBox())!;
|
||||
const dateLabel = (await popup.getByText("Author date", { exact: true }).boundingBox())!;
|
||||
const clearBox = (await clear.boundingBox())!;
|
||||
expect(authorBox.x).toBeCloseTo(dateBox.x, 0);
|
||||
expect(dateLabel.y).toBeGreaterThanOrEqual(dateBox.y);
|
||||
expect(dateLabel.y).toBeLessThan(dateBox.y + dateBox.height);
|
||||
expect(clearBox.x + clearBox.width).toBeCloseTo(authorBox.x + authorBox.width, 0);
|
||||
await expect(clear).toBeInViewport({ ratio: 1 });
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popup).toBeHidden();
|
||||
await page.evaluate(async () => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, vcs: { ...settings?.vcs, commit: { ...settings?.vcs?.commit, nonModal: false } } },
|
||||
});
|
||||
});
|
||||
await page.setViewportSize({ width: 650, height: 650 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
const dialog = page.getByRole("dialog", { name: "Commit Changes", exact: true });
|
||||
const options = dialog.getByRole("group", { name: "Commit Options", exact: true });
|
||||
const compactAuthor = options.getByRole("textbox", { name: "Author", exact: true });
|
||||
const compactDate = options.getByLabel("Author date", { exact: true });
|
||||
const compactClear = options.getByRole("button", { name: "Clear author date", exact: true });
|
||||
await expect(compactAuthor).toHaveValue(name);
|
||||
await expect(compactDate).toHaveValue(time);
|
||||
const labelBox = (await options.getByText("Author:", { exact: true }).boundingBox())!;
|
||||
const inputBox = (await compactAuthor.boundingBox())!;
|
||||
expect(inputBox.x).toBeCloseTo(labelBox.x, 0);
|
||||
expect(inputBox.y).toBeGreaterThanOrEqual(labelBox.y + labelBox.height);
|
||||
const box = (await compactDate.boundingBox())!;
|
||||
const buttonBox = (await compactClear.boundingBox())!;
|
||||
expect(box.width).toBeCloseTo(inputBox.width, 0);
|
||||
expect(buttonBox.y).toBeGreaterThanOrEqual(box.y + box.height);
|
||||
expect(await options.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await compactClear.click();
|
||||
await expect(compactDate).toHaveValue("");
|
||||
await expect(compactClear).toBeHidden();
|
||||
await expect(compactAuthor).toHaveValue(name);
|
||||
});
|
||||
|
||||
test("the Commit window gives its message preferred focus", async ({ workbench: page }) => {
|
||||
await stubRepository(page);
|
||||
const stripe = page.locator('[data-stripe-button="commit"]');
|
||||
@@ -780,81 +720,6 @@ 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,
|
||||
}) => {
|
||||
@@ -1159,51 +1024,27 @@ test("the Commit tool window restores the draft and author options for the inclu
|
||||
await expect(message).toHaveValue("Default draft");
|
||||
});
|
||||
|
||||
test("commit message history shows compact message previews above the editor", async ({ workbench: page }) => {
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
|
||||
await stubRepository(page);
|
||||
await page.keyboard.press("Meta+k");
|
||||
const message = page.getByRole("textbox", { name: "Commit message" });
|
||||
await expect(message).toBeVisible();
|
||||
await page.evaluate((root) => {
|
||||
localStorage.setItem(
|
||||
`openidea.vcs.commitMessages:${root}`,
|
||||
JSON.stringify([
|
||||
"Update inventory\n\nReview settlement totals",
|
||||
"Update inventory\n\nReconcile export records",
|
||||
...Array.from({ length: 7 }, (_, index) => `Earlier message ${index + 1}`),
|
||||
]),
|
||||
);
|
||||
localStorage.setItem(`openidea.vcs.commitMessages:${root}`, JSON.stringify(["Previous commit message"]));
|
||||
}, ROOT);
|
||||
await message.fill("Draft");
|
||||
const history = page.getByRole("button", { name: "Commit Message History" });
|
||||
await history.click();
|
||||
await page.getByRole("button", { name: "Commit Message History" }).click();
|
||||
|
||||
const menu = page.getByRole("menu", { name: "Recent commit messages" });
|
||||
const row = menu.getByRole("menuitem", { name: /Update inventory.*Review settlement totals/ });
|
||||
const row = menu.getByRole("menuitem", { name: "Previous commit message" });
|
||||
await expect(row).toBeVisible();
|
||||
const messageBox = (await message.boundingBox())!;
|
||||
const menuBox = (await menu.locator("..").boundingBox())!;
|
||||
const rowBox = (await row.boundingBox())!;
|
||||
expect(messageBox.y - menuBox.y - menuBox.height).toBeCloseTo(3, 0);
|
||||
expect(Math.abs(menuBox.x - messageBox.x)).toBeLessThan(2);
|
||||
expect(menuBox.height).toBeLessThan(rowBox.height * 8);
|
||||
await expect(row).toHaveCSS("font-family", await message.evaluate((el) => getComputedStyle(el).fontFamily));
|
||||
await expect(row).toHaveCSS("font-size", await message.evaluate((el) => getComputedStyle(el).fontSize));
|
||||
const messageBox = await message.boundingBox();
|
||||
const menuBox = await menu.locator("..").boundingBox();
|
||||
expect(messageBox).not.toBeNull();
|
||||
expect(menuBox).not.toBeNull();
|
||||
expect(menuBox!.y + menuBox!.height).toBeLessThan(messageBox!.y);
|
||||
expect(Math.abs(menuBox!.x - messageBox!.x)).toBeLessThan(2);
|
||||
await expect(row.locator("span")).toHaveCount(1);
|
||||
|
||||
await row.press("Escape");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(message).toHaveValue("Draft");
|
||||
await history.click();
|
||||
await row.press("Home");
|
||||
await expect(row).toBeFocused();
|
||||
await page.keyboard.press("ArrowDown");
|
||||
const second = menu.getByRole("menuitem", { name: /Update inventory.*Reconcile export records/ });
|
||||
await expect(second).toBeFocused();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(message).toHaveValue("Update inventory\n\nReconcile export records");
|
||||
await expect(message).toBeFocused();
|
||||
});
|
||||
|
||||
test("Amend shows the original author and warns when the committer differs", async ({ workbench: page }) => {
|
||||
@@ -1314,60 +1155,6 @@ async function stubEarlierAmend(page: Page) {
|
||||
});
|
||||
}
|
||||
|
||||
test("Amend sizes the chooser for long subjects while keeping the last commit action distinct", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubEarlierAmend(page);
|
||||
const tip = "Record regional settlement adjustments across the quarterly audit and reconciliation reports";
|
||||
const earlier = "Expand the warehouse reconciliation report with monthly ledger and inventory audit totals";
|
||||
await page.evaluate(
|
||||
({ tip, earlier }) => {
|
||||
const handlers = window.__ipc.handlers;
|
||||
const log = handlers.vcs_log!;
|
||||
handlers.vcs_log = (args) =>
|
||||
(log(args) as { id: string; summary: string; message: string }[]).map((commit) => {
|
||||
const subject = commit.id === "1111111" ? tip : commit.id === "aaaaaaa" ? earlier : commit.summary;
|
||||
return { ...commit, summary: subject, message: subject };
|
||||
});
|
||||
},
|
||||
{ tip, earlier },
|
||||
);
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
const panel = page.getByRole("region", { name: "Commit", exact: true });
|
||||
const choose = panel.getByRole("button", { name: "Choose Commit to Amend", exact: true });
|
||||
await choose.click();
|
||||
const list = page.getByRole("listbox", { name: "Choose Commit to Amend", exact: true });
|
||||
const popup = list.locator("xpath=ancestor::*[@data-popup]");
|
||||
const search = popup.getByRole("textbox", { name: "Search commits", exact: true });
|
||||
const last = list.getByRole("option", { name: /^Amend Last Commit/ });
|
||||
const previous = list.getByRole("option", { name: earlier, exact: true });
|
||||
|
||||
await expect(previous).toBeVisible();
|
||||
const wide = (await popup.boundingBox())!;
|
||||
expect(wide.width).toBeGreaterThan(360);
|
||||
expect(wide.width).toBeLessThanOrEqual(522);
|
||||
await expect(last.getByText("Amend Last Commit", { exact: true })).toHaveCSS("font-weight", "600");
|
||||
await expect(last.getByText(tip, { exact: true })).toHaveAttribute("title", tip);
|
||||
await expect(previous.getByText(earlier, { exact: true })).toHaveAttribute("title", earlier);
|
||||
|
||||
await page.setViewportSize({ width: 440, height: 520 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const box = (await popup.boundingBox())!;
|
||||
return box.x >= 0 && box.x + box.width <= 440 && box.width < wide.width;
|
||||
})
|
||||
.toBe(true);
|
||||
await expect(search).toBeFocused();
|
||||
await search.fill("inventory audit");
|
||||
await expect(previous).toBeVisible();
|
||||
await search.press("Enter");
|
||||
await expect(list).toBeHidden();
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
await expect(panel.getByRole("textbox", { name: "Commit message" })).toHaveValue(earlier);
|
||||
});
|
||||
|
||||
test("Amend can select an earlier commit before protected history", async ({ workbench: page }) => {
|
||||
await stubEarlierAmend(page);
|
||||
await page.keyboard.press("Meta+k");
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* with its frames and variables, and stepping and resuming go back to the adapter. The adapter is
|
||||
* stubbed at the IPC layer; `crates/ide-dap/tests` drives real ones.
|
||||
*/
|
||||
import type { JvmMemoryResult } from "../src/platform/ipc";
|
||||
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const ROOT = "/dev/acme-api";
|
||||
@@ -115,83 +114,6 @@ test("stops at a breakpoint, shows frames and variables, steps and resumes", asy
|
||||
await expect(debug.getByText("CreateOrderRequest(sku='A-1', qty=2)")).toBeHidden();
|
||||
});
|
||||
|
||||
test("Memory gives class filtering the available toolbar width and exposes changed-only filtering", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const rows = [
|
||||
{ name: "OrderCache", instances: 64, deltaInstances: 12 },
|
||||
{ name: "OrderRepository", instances: 16, deltaInstances: 0 },
|
||||
].map((row) => ({ ...row, bytes: row.instances * 16, deltaBytes: null, module: null, ambiguous: false }));
|
||||
const result: JvmMemoryResult = {
|
||||
status: "ready",
|
||||
snapshot: {
|
||||
rows,
|
||||
totalInstances: 80,
|
||||
totalBytes: 1280,
|
||||
javaVersion: "21",
|
||||
takenWhileSuspended: true,
|
||||
hasBaseline: true,
|
||||
elapsedMs: 5,
|
||||
source: "debugger",
|
||||
},
|
||||
};
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ result, id }) => {
|
||||
const caps = { jvmMemory: true, jvmHeap: true };
|
||||
window.__ipc.handlers.debug_capabilities = () => caps;
|
||||
window.__ipc.handlers.debug_jvm_memory_classes = () => result;
|
||||
const debugPath = "/src/features/debugger/state.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugPath);
|
||||
adoptSession(id, { adapter: "java-debug", name: "Billing Service", status: "paused", caps });
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "bottom");
|
||||
layout.setToolWindowSize("bottom", 300);
|
||||
layout.showToolWindow("debug", true);
|
||||
},
|
||||
{ result, id: SESSION },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Memory" }).click();
|
||||
const toolbar = debug.getByRole("toolbar", { name: "Memory", exact: true });
|
||||
const filter = toolbar.getByRole("textbox", { name: "Filter classes" });
|
||||
const options = toolbar.getByRole("button", { name: "View Options" });
|
||||
const grid = debug.getByRole("grid", { name: "Memory", exact: true });
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
expect((await filter.boundingBox())!.width).toBeGreaterThan((await toolbar.boundingBox())!.width / 2);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "right");
|
||||
layout.setToolWindowSize("right", 330);
|
||||
});
|
||||
await expect.poll(async () => (await toolbar.boundingBox())!.width).toBeCloseTo(330, 0);
|
||||
const bar = (await toolbar.boundingBox())!;
|
||||
const gear = (await options.boundingBox())!;
|
||||
const input = (await filter.boundingBox())!;
|
||||
expect(input.width).toBeGreaterThan(bar.width / 2);
|
||||
expect(input.x + input.width).toBeLessThan(gear.x);
|
||||
expect(gear.x + gear.width).toBeLessThanOrEqual(bar.x + bar.width);
|
||||
|
||||
await filter.fill("cache");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await toolbar.getByRole("button", { name: "Clear", exact: true }).click();
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
|
||||
await options.press("Enter");
|
||||
const changed = page.getByRole("menuitemcheckbox", { name: "Changed only" });
|
||||
await expect(changed).not.toBeChecked();
|
||||
await changed.press("Enter");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(options).toBeFocused();
|
||||
await options.press("Enter");
|
||||
await expect(changed).toBeChecked();
|
||||
});
|
||||
|
||||
test("Evaluate keeps a multiline expression and its result visible in a short dialog", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 580, height: 420 });
|
||||
await stubDesktop(page);
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function openTable(page: Page, columns: number) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (columns) => {
|
||||
window.__ipc.handlers.debug_evaluate_in = ({ expression }) => {
|
||||
const query = String(expression);
|
||||
const sliced = query.includes("totals.iloc[:2, :2]");
|
||||
const visibleColumns = sliced ? 2 : Math.min(30, columns);
|
||||
const columnsInFrame = sliced ? 2 : columns;
|
||||
const start = query.includes("100, 100,") ? 100 : 0;
|
||||
const rows = sliced ? 2 : 220;
|
||||
const count = sliced ? 2 : 100;
|
||||
const result = query.includes("missing_table")
|
||||
? { error: "NameError: missing_table" }
|
||||
: {
|
||||
kind: "frame",
|
||||
shape: [rows, columnsInFrame],
|
||||
rows,
|
||||
columns: columnsInFrame,
|
||||
headers: Array.from({ length: visibleColumns }, (_, i) => `Amount ${i + 1}`),
|
||||
dtypes: Array.from({ length: visibleColumns }, () => "int64"),
|
||||
index: Array.from({ length: count }, (_, i) => String(i + start)),
|
||||
cells: Array.from({ length: count }, (_, row) =>
|
||||
Array.from({ length: visibleColumns }, (_, column) => String((row + start + 1) * 10 + column)),
|
||||
),
|
||||
};
|
||||
return {
|
||||
name: "",
|
||||
value: JSON.stringify(JSON.stringify(result)),
|
||||
typeName: "str",
|
||||
variablesReference: 0,
|
||||
evaluateName: null,
|
||||
};
|
||||
};
|
||||
const stateModule = "/src/features/debugger/state.ts";
|
||||
const overlaysModule = "/src/features/debugger/ui/popoverStore.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ stateModule);
|
||||
const { openTableView } = await import(/* @vite-ignore */ overlaysModule);
|
||||
adoptSession(91, { name: "Settlement review", adapter: "debugpy", status: "paused", selectedFrame: 11 });
|
||||
openTableView("totals", 91);
|
||||
}, columns);
|
||||
const dialog = page.getByRole("dialog", { name: "Table view of totals", exact: true });
|
||||
await expect(dialog.getByRole("table")).toBeVisible();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
test("View as Table gives the grid the dialog width and puts the expression below it", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 760 });
|
||||
const dialog = await openTable(page, 3);
|
||||
const scroll = dialog.getByRole("region", { name: "Table", exact: true });
|
||||
const grid = dialog.getByRole("table");
|
||||
const expression = dialog.getByRole("textbox", { name: "Expression", exact: true });
|
||||
const shape = dialog.getByText("Shape (220, 3)", { exact: true });
|
||||
const body = (await scroll.boundingBox())!;
|
||||
const input = (await expression.boundingBox())!;
|
||||
expect(input.y).toBeGreaterThan(body.y + body.height);
|
||||
expect((await shape.boundingBox())!.y).toBeLessThan(body.y);
|
||||
expect(Math.abs((await grid.boundingBox())!.width - (await scroll.evaluate((el) => el.clientWidth)))).toBeLessThan(1);
|
||||
expect((await dialog.boundingBox())!.width).toBeCloseTo(700, 0);
|
||||
await expect(expression).toBeFocused();
|
||||
await expect(grid).toHaveCSS("font-family", /Inter/);
|
||||
await expect(grid.getByRole("columnheader").nth(1)).toHaveCSS("text-align", "center");
|
||||
await expect(grid.getByRole("rowheader").first()).toHaveCSS("text-align", "center");
|
||||
await expect(grid.getByRole("cell").first()).toHaveCSS("text-align", /^(start|left)$/);
|
||||
});
|
||||
|
||||
test("View as Table keeps paging, slice input and Close usable in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 450, height: 620 });
|
||||
const dialog = await openTable(page, 36);
|
||||
const expression = dialog.getByRole("textbox", { name: "Expression", exact: true });
|
||||
const scroll = dialog.getByRole("region", { name: "Table", exact: true });
|
||||
const rows = dialog.getByRole("button", { name: "Next Rows", exact: true });
|
||||
const columns = dialog.getByRole("button", { name: "Next Columns", exact: true });
|
||||
const close = dialog.getByRole("button", { name: "Close", exact: true }).filter({ hasText: /^Close$/ });
|
||||
const input = (await expression.boundingBox())!;
|
||||
const grid = (await scroll.boundingBox())!;
|
||||
expect(input.y).toBeGreaterThan(grid.y + grid.height);
|
||||
expect(input.width).toBeCloseTo(grid.width, 0);
|
||||
for (const control of [expression, rows, columns, close]) await expect(control).toBeInViewport({ ratio: 0.98 });
|
||||
await scroll.evaluate((el) => {
|
||||
el.scrollLeft = 300;
|
||||
el.scrollTop = 150;
|
||||
});
|
||||
await expect(dialog.getByRole("rowheader").filter({ hasText: /^9$/ })).toBeInViewport({ ratio: 0.98 });
|
||||
await rows.click();
|
||||
await expect(dialog.getByText("Rows 101–200 of 220", { exact: true })).toBeVisible();
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "debug_evaluate_in"))
|
||||
.toContainEqual(expect.objectContaining({ expression: expect.stringContaining("100, 100, 0, 30") }));
|
||||
await expression.fill("totals.iloc[:2, :2]");
|
||||
await expression.press("Enter");
|
||||
const sliced = page.getByRole("dialog", { name: "Table view of totals.iloc[:2, :2]", exact: true });
|
||||
await expect(sliced.getByText("Shape (2, 2)", { exact: true })).toBeVisible();
|
||||
const slicedExpression = sliced.getByRole("textbox", { name: "Expression", exact: true });
|
||||
await slicedExpression.fill("missing_table");
|
||||
await slicedExpression.press("Enter");
|
||||
const failed = page.getByRole("dialog", { name: "Table view of missing_table", exact: true });
|
||||
const alert = failed.getByRole("alert");
|
||||
await expect(alert).toHaveText("NameError: missing_table");
|
||||
expect((await alert.boundingBox())!.y).toBeGreaterThan(
|
||||
(await failed.getByRole("textbox", { name: "Expression", exact: true }).boundingBox())!.y,
|
||||
);
|
||||
await failed
|
||||
.getByRole("button", { name: "Close", exact: true })
|
||||
.filter({ hasText: /^Close$/ })
|
||||
.click();
|
||||
await expect(failed).toHaveCount(0);
|
||||
});
|
||||
@@ -88,40 +88,3 @@ test("a close button on the left keeps a narrow slot before the icon", async ({
|
||||
const slot = await box(closeOf(selected));
|
||||
expect(slot.x + slot.width).toBeLessThanOrEqual(label.x + 0.5);
|
||||
});
|
||||
|
||||
test("a pinned editor tab uses the close slot and can be unpinned from it", async ({ workbench: page }) => {
|
||||
await openFromTree(page, "README.md");
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
const strip = page.getByRole("tablist", { name: "Editor tabs" });
|
||||
const unpinned = strip.getByRole("tab", { name: "build.gradle.kts", exact: true });
|
||||
const pinned = strip.getByRole("tab", { name: "build.gradle.kts Pinned", exact: true });
|
||||
const menu = page.getByRole("menu", { name: "Context menu" });
|
||||
const pin = async () => {
|
||||
await unpinned.click({ button: "right" });
|
||||
await menu.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
|
||||
};
|
||||
await pin();
|
||||
const unpin = pinned.locator("..").getByRole("button", { name: "Unpin Tab", exact: true });
|
||||
|
||||
for (const closeButtonPosition of ["right", "left"]) {
|
||||
await setTabs(page, { closeButtonPosition });
|
||||
await expect(closeOf(pinned)).toHaveCount(0);
|
||||
const tab = await box(pinned.locator(".."));
|
||||
const action = await box(unpin);
|
||||
const label = await box(pinned.locator(":scope > span"));
|
||||
const inset = closeButtonPosition === "left" ? action.x - tab.x : tab.x + tab.width - action.x - action.width;
|
||||
expect(inset).toBeCloseTo(2, 0);
|
||||
expect(action.width).toBeCloseTo(16, 0);
|
||||
if (closeButtonPosition === "left") expect(action.x + action.width).toBeLessThanOrEqual(label.x);
|
||||
else expect(action.x).toBeGreaterThanOrEqual(label.x + label.width);
|
||||
}
|
||||
|
||||
await setTabs(page, { showCloseButton: false });
|
||||
await unpin.click();
|
||||
await expect(unpinned).toHaveAttribute("aria-selected", "true");
|
||||
await expect(closeOf(unpinned)).toHaveCount(0);
|
||||
|
||||
await pin();
|
||||
await pinned.click({ button: "middle" });
|
||||
await expect(pinned).toHaveCount(0);
|
||||
});
|
||||
@@ -1,81 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function openEditorTabsSettings(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("file.settings", "editor.general.editorTabs");
|
||||
});
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await expect(dialog.getByRole("region", { name: "Closing Policy", exact: true })).toBeVisible();
|
||||
return dialog;
|
||||
}
|
||||
|
||||
test("Editor Tabs aligns appearance fields and stacks closing choices at both widths", async ({ workbench: page }) => {
|
||||
const settings = await openEditorTabsSettings(page);
|
||||
const appearance = settings.getByRole("region", { name: "Appearance", exact: true });
|
||||
const placement = appearance.getByRole("button", { name: "Tab placement", exact: true });
|
||||
const closePosition = appearance.getByRole("button", { name: "Close button position", exact: true });
|
||||
const closing = settings.getByRole("region", { name: "Closing Policy", exact: true });
|
||||
const limit = closing.getByRole("textbox", { name: "Tab limit", exact: true });
|
||||
const footer = settings.getByRole("button", { name: "OK", exact: true });
|
||||
|
||||
for (const width of [1100, 580]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
const placementBox = (await placement.boundingBox())!;
|
||||
const closeBox = (await closePosition.boundingBox())!;
|
||||
expect(Math.abs(placementBox.x - closeBox.x)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(placementBox.width - closeBox.width)).toBeLessThanOrEqual(1);
|
||||
await expect(placement).toBeInViewport();
|
||||
await expect(limit).toHaveValue("30");
|
||||
|
||||
for (const name of ["When the tab limit is reached", "When the current tab is closed, activate"]) {
|
||||
const choices = closing.getByRole("radiogroup", { name, exact: true }).getByRole("radio");
|
||||
const first = (await choices.first().boundingBox())!;
|
||||
const last = (await choices.last().boundingBox())!;
|
||||
expect(Math.abs(first.x - last.x)).toBeLessThanOrEqual(1);
|
||||
expect(last.y).toBeGreaterThan(first.y + first.height);
|
||||
expect(last.x + last.width).toBeLessThanOrEqual(width);
|
||||
}
|
||||
await expect(footer).toBeInViewport();
|
||||
}
|
||||
});
|
||||
|
||||
test("Editor Tabs keeps row and overflow choices independently selected and keyboard operable", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const settings = await openEditorTabsSettings(page);
|
||||
const group = settings.getByRole("radiogroup", { name: "Show tabs in", exact: true });
|
||||
const one = group.getByRole("radio", { name: /^One row/ });
|
||||
const multiple = group.getByRole("radio", { name: "Multiple rows", exact: true });
|
||||
const scroll = group.getByRole("radio", { name: "Scroll the tabs panel", exact: true });
|
||||
const squeeze = group.getByRole("radio", { name: "Squeeze tabs", exact: true });
|
||||
await expect(one).toBeChecked();
|
||||
await expect(scroll).toBeChecked();
|
||||
const oneBox = (await one.boundingBox())!;
|
||||
const scrollBox = (await scroll.boundingBox())!;
|
||||
const multipleBox = (await multiple.boundingBox())!;
|
||||
expect(scrollBox.x).toBeGreaterThan(oneBox.x + 8);
|
||||
expect(scrollBox.y).toBeGreaterThan(oneBox.y);
|
||||
expect(Math.abs(multipleBox.x - oneBox.x)).toBeLessThanOrEqual(1);
|
||||
expect(multipleBox.y).toBeGreaterThan(scrollBox.y);
|
||||
|
||||
await scroll.press("ArrowDown");
|
||||
await expect(squeeze).toBeFocused();
|
||||
await expect(squeeze).toBeChecked();
|
||||
await expect(one).toBeChecked();
|
||||
await one.press("ArrowDown");
|
||||
await expect(multiple).toBeFocused();
|
||||
await expect(multiple).toBeChecked();
|
||||
await expect(squeeze).toBeDisabled();
|
||||
await expect(squeeze).toBeChecked();
|
||||
await multiple.press("ArrowUp");
|
||||
await expect(one).toBeChecked();
|
||||
await expect(squeeze).toBeEnabled();
|
||||
await settings.getByRole("button", { name: "OK", exact: true }).click();
|
||||
|
||||
const reopened = await openEditorTabsSettings(page);
|
||||
await expect(reopened.getByRole("radio", { name: /^One row/ })).toBeChecked();
|
||||
await expect(reopened.getByRole("radio", { name: "Squeeze tabs", exact: true })).toBeChecked();
|
||||
});
|
||||
@@ -1,80 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
const root = "/dev/acme-api";
|
||||
const stem = "InternationalSettlementRegionalReconciliationAndAuditWarehouseAllocationConfiguration";
|
||||
const original = stem + ".txt";
|
||||
const renamed = "WarehouseAllocation.txt";
|
||||
|
||||
test("file rename groups the name and reflows the options without losing validation", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1000, height: 700 });
|
||||
await page.evaluate(
|
||||
async ({ root, original }) => {
|
||||
const fsModule = "/src/features/project-tree/fs.ts";
|
||||
const storeModule = "/src/features/project-tree/store.ts";
|
||||
const { projectFs } = await import(/* @vite-ignore */ fsModule);
|
||||
const { loadDir } = await import(/* @vite-ignore */ storeModule);
|
||||
await projectFs(root).createFile(root + "/" + original);
|
||||
await loadDir(root, true);
|
||||
},
|
||||
{ root, original },
|
||||
);
|
||||
const source = page.getByRole("treeitem", { name: original, exact: true });
|
||||
await source.click();
|
||||
await page.keyboard.press("Shift+F6");
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Rename", exact: true });
|
||||
const prompt = dialog.getByText("Rename file '" + original + "' and its usages to:", { exact: true });
|
||||
const field = dialog.getByRole("textbox", { name: "New name" });
|
||||
const references = dialog.getByRole("checkbox", { name: "Search for references" });
|
||||
const comments = dialog.getByRole("checkbox", { name: "Search in comments and strings" });
|
||||
const submit = dialog.getByRole("button", { name: "Refactor", exact: true });
|
||||
const referencesRow = references.locator("xpath=ancestor::label");
|
||||
const commentsRow = comments.locator("xpath=ancestor::label");
|
||||
|
||||
await expect(field).toBeFocused();
|
||||
const selected = await field.evaluate((el: HTMLInputElement) => el.value.slice(el.selectionStart!, el.selectionEnd!));
|
||||
expect(selected).toBe(stem);
|
||||
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const a = (await prompt.boundingBox())!;
|
||||
const b = (await field.boundingBox())!;
|
||||
return b.y - a.y - a.height;
|
||||
})
|
||||
.toBeCloseTo(4, 0);
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const a = (await referencesRow.boundingBox())!;
|
||||
const b = (await commentsRow.boundingBox())!;
|
||||
return Math.abs(a.y - b.y) < 1 && b.x >= a.x + a.width;
|
||||
})
|
||||
.toBe(true);
|
||||
|
||||
await field.fill("README.md");
|
||||
await expect(dialog.getByRole("alert")).toBeVisible();
|
||||
await expect(submit).toBeDisabled();
|
||||
await page.setViewportSize({ width: 400, height: 520 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const a = (await referencesRow.boundingBox())!;
|
||||
const b = (await commentsRow.boundingBox())!;
|
||||
return b.y >= a.y + a.height;
|
||||
})
|
||||
.toBe(true);
|
||||
await expect(field).toHaveValue("README.md");
|
||||
await expect(prompt).toBeInViewport({ ratio: 1 });
|
||||
await expect(submit).toBeInViewport({ ratio: 1 });
|
||||
expect(
|
||||
await dialog.locator("[data-dialog-body]").evaluate((node) => node.scrollWidth - node.clientWidth),
|
||||
).toBeLessThanOrEqual(1);
|
||||
|
||||
await field.fill(renamed);
|
||||
await expect(dialog.getByRole("alert")).toBeHidden();
|
||||
await references.uncheck();
|
||||
await comments.uncheck();
|
||||
await submit.click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await page.setViewportSize({ width: 1000, height: 700 });
|
||||
await expect(page.getByRole("treeitem", { name: renamed, exact: true })).toBeVisible();
|
||||
await expect(source).toHaveCount(0);
|
||||
});
|
||||
@@ -1,78 +0,0 @@
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
|
||||
const latest = "regional-order-reconciliation-endpoints-for-sandbox-environments/".repeat(3) + "checkout\nText to find";
|
||||
|
||||
async function seedHistory(page: Page, kind: "find" | "replace") {
|
||||
await page.evaluate(
|
||||
async ({ kind, latest }) => {
|
||||
const searchModule = "/src/platform/search.ts";
|
||||
const { rememberSearch } = await import(/* @vite-ignore */ searchModule);
|
||||
for (let i = 0; i < 19; i++) rememberSearch(kind, `Order rule ${i}`);
|
||||
rememberSearch(kind, latest);
|
||||
},
|
||||
{ kind, latest },
|
||||
);
|
||||
}
|
||||
|
||||
async function openHistory(field: Locator, menu: Locator) {
|
||||
await field.focus();
|
||||
await field.press("Alt+ArrowDown");
|
||||
await expect(menu).toBeVisible();
|
||||
}
|
||||
|
||||
test("editor find history grows with the field and restores the original query", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
await page.keyboard.press("Meta+f");
|
||||
await seedHistory(page, "find");
|
||||
|
||||
const field = page.getByRole("textbox", { name: "Find", exact: true });
|
||||
const menu = page.getByRole("menu", { name: "Recent Searches", exact: true });
|
||||
await openHistory(field, menu);
|
||||
|
||||
const newest = menu.getByRole("menuitem").first();
|
||||
await expect(newest).toHaveText(latest.replace("\n", " ⏎ "));
|
||||
await expect(newest).toHaveAttribute("title", latest);
|
||||
await expect.poll(async () => (await menu.boundingBox())!.width).toBeGreaterThan(420);
|
||||
await newest.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(field).toHaveValue(latest);
|
||||
await expect(field).toBeFocused();
|
||||
});
|
||||
|
||||
test("project replacement history stays inside a narrow window and keeps its heading visible", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 440, height: 520 });
|
||||
await page.keyboard.press("Meta+Shift+r");
|
||||
await seedHistory(page, "replace");
|
||||
|
||||
const field = page.getByRole("textbox", { name: "Replace with" });
|
||||
const menu = page.getByRole("menu", { name: "Recent Replacements" });
|
||||
await openHistory(field, menu);
|
||||
|
||||
const popup = menu.locator("..");
|
||||
const heading = popup.getByText("Recent Replacements", { exact: true });
|
||||
const newest = menu.getByRole("menuitem").first();
|
||||
await expect(newest).toHaveText(latest.replace("\n", " ⏎ "));
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const { x, width } = (await popup.boundingBox())!;
|
||||
return x >= 0 && x + width <= 440;
|
||||
})
|
||||
.toBe(true);
|
||||
|
||||
await newest.press("End");
|
||||
const oldest = menu.getByRole("menuitem").last();
|
||||
await expect(oldest).toBeFocused();
|
||||
await expect.poll(async () => popup.evaluate((node) => node.scrollTop)).toBeGreaterThan(0);
|
||||
await expect(heading).toBeInViewport();
|
||||
|
||||
await oldest.press("Home");
|
||||
await expect(newest).toBeFocused();
|
||||
await newest.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
await expect(field).toHaveValue(latest);
|
||||
await expect(field).toBeFocused();
|
||||
});
|
||||
@@ -1,66 +1,6 @@
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Find Usages places read and write filters with the other actions", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const modulePath = "/src/features/code-insight/usages.ts";
|
||||
const { useUsagesPopup } = await import(modulePath);
|
||||
const path = "/dev/acme-api/src/SettlementService.ts";
|
||||
const lines = ["const current = settlement;", "settlement = next;"];
|
||||
window.__ipc.handlers.fs_read_text = () => lines.join("\n");
|
||||
useUsagesPopup.setState({
|
||||
open: true,
|
||||
anchor: { x: 100, y: 150 },
|
||||
symbol: "settlement",
|
||||
loading: false,
|
||||
scope: "project",
|
||||
groups: [
|
||||
{
|
||||
path,
|
||||
usages: lines.map((text, line) => ({
|
||||
path,
|
||||
line,
|
||||
col: text.indexOf("settlement"),
|
||||
endCol: text.indexOf("settlement") + "settlement".length,
|
||||
text,
|
||||
access: line === 0 ? "read" : "write",
|
||||
})),
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
|
||||
const read = { name: "Show read accesses", exact: true };
|
||||
const write = { name: "Show write accesses", exact: true };
|
||||
const actions = popup.getByRole("button", { name: "Show Preview", exact: true }).locator("..");
|
||||
await expect(popup.getByRole("option")).toHaveCount(2);
|
||||
for (const width of [1120, 540]) {
|
||||
await page.setViewportSize({ width, height: 640 });
|
||||
expect(await actions.getByRole("toolbar", { name: "Usage access filters", exact: true }).count()).toBe(1);
|
||||
await expect(actions.getByRole("button", read)).toBeInViewport({ ratio: 1 });
|
||||
await expect(actions.getByRole("button", write)).toBeInViewport({ ratio: 1 });
|
||||
}
|
||||
await actions.getByRole("button", write).click();
|
||||
await expect(popup.getByRole("option")).toHaveCount(1);
|
||||
await popup.getByRole("button", { name: /Open in Find Window/ }).click();
|
||||
|
||||
const view = page.getByRole("region", { name: "Find Usages", exact: true });
|
||||
const toolbar = view.getByRole("toolbar", { name: "Usages actions", exact: true });
|
||||
const readButton = toolbar.getByRole("button", read);
|
||||
const writeButton = toolbar.getByRole("button", write);
|
||||
await expect(readButton).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(writeButton).toHaveAttribute("aria-pressed", "false");
|
||||
const a = (await readButton.boundingBox())!;
|
||||
const b = (await writeButton.boundingBox())!;
|
||||
expect(a.x).toBeCloseTo(b.x, 0);
|
||||
expect(b.y).toBeGreaterThanOrEqual(a.y + a.height);
|
||||
await expect(view.locator("mark")).toHaveCount(1);
|
||||
await writeButton.click();
|
||||
await expect(view.locator("mark")).toHaveCount(2);
|
||||
});
|
||||
|
||||
async function checkSize(icon: Locator, size = 16) {
|
||||
const dimensions = await icon.evaluate((node) => {
|
||||
const style = getComputedStyle(node);
|
||||
|
||||
@@ -3,12 +3,11 @@ import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
test("Git annotations align dates and full author names at UI text size", async ({ workbench: page }) => {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
await stubDesktop(page);
|
||||
const longEmail = `reconciliation+${"regional-settlement-".repeat(5)}[email protected]`;
|
||||
await page.evaluate(async (email) => {
|
||||
await page.evaluate(async () => {
|
||||
const root = "/dev/acme-api";
|
||||
const file = `${root}/build.gradle.kts`;
|
||||
const handlers = window.__ipc.handlers;
|
||||
const lines = [
|
||||
handlers.vcs_blame = () => [
|
||||
{
|
||||
commit: "a1234567".padEnd(40, "a"),
|
||||
author: "Lena Park",
|
||||
@@ -22,23 +21,6 @@ test("Git annotations align dates and full author names at UI text size", async
|
||||
summary: "Review totals",
|
||||
},
|
||||
];
|
||||
handlers.vcs_blame = () => lines;
|
||||
handlers.vcs_log = ({ query }) => {
|
||||
const { branch } = query as { branch?: string };
|
||||
const line = lines.find(({ commit }) => commit === branch);
|
||||
if (!line) return [];
|
||||
return [
|
||||
{
|
||||
...line,
|
||||
id: line.commit,
|
||||
shortId: line.commit.slice(0, 8),
|
||||
refs: [],
|
||||
parents: [],
|
||||
email: line === lines[0] ? "[email protected]" : email,
|
||||
message: line.summary,
|
||||
},
|
||||
];
|
||||
};
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings } = useProject.getState();
|
||||
@@ -57,7 +39,7 @@ test("Git annotations align dates and full author names at UI text size", async
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("vcs.annotate", file);
|
||||
}, longEmail);
|
||||
});
|
||||
|
||||
const gutter = editor.locator(".cm-vcs-blame");
|
||||
const first = gutter.locator("[data-commit]").filter({ hasText: "3 May 2026" });
|
||||
@@ -69,21 +51,6 @@ test("Git annotations align dates and full author names at UI text size", async
|
||||
await expect
|
||||
.poll(async () => Math.abs((await firstAuthor.boundingBox())!.x - (await secondAuthor.boundingBox())!.x))
|
||||
.toBeLessThan(1);
|
||||
|
||||
await first.hover();
|
||||
const details = page.getByRole("dialog").filter({ has: page.getByTitle("Show Commit in Git Log") });
|
||||
await expect(details).toContainText("[email protected]");
|
||||
await expect.poll(async () => (await details.boundingBox())!.width).toBeLessThan(400);
|
||||
await expect(details.getByTitle("Show Commit in Git Log")).toHaveCSS(
|
||||
"font-family",
|
||||
await details.evaluate((el) => getComputedStyle(el).fontFamily),
|
||||
);
|
||||
|
||||
await page.setViewportSize({ width: 430, height: 640 });
|
||||
await second.hover();
|
||||
await expect(details).toContainText(longEmail);
|
||||
await expect(details).toBeInViewport({ ratio: 1 });
|
||||
await expect.poll(() => details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
const uiSize = await editor.evaluate((el) => getComputedStyle(el).getPropertyValue("--fs-ui").trim());
|
||||
await expect(firstAuthor).toHaveCSS("font-size", uiSize);
|
||||
|
||||
|
||||
@@ -12,30 +12,6 @@ const names = [
|
||||
"InvoicePublisher.ts",
|
||||
];
|
||||
|
||||
test("a pinned editor tab can be unpinned from the hidden tabs list", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 700, height: 650 });
|
||||
await page.evaluate(async (first) => {
|
||||
const module = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ module);
|
||||
await editorService().openFile(`/dev/acme-api/${first}`);
|
||||
}, names[0]!);
|
||||
const strip = page.getByRole("tablist", { name: "Editor tabs" });
|
||||
const tab = strip.getByRole("tab", { name: names[0], exact: true });
|
||||
await tab.click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Pin Tab", exact: true }).click();
|
||||
await page.evaluate(async (files) => {
|
||||
const module = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ module);
|
||||
for (const name of files) await editorService().openFile(`/dev/acme-api/${name}`);
|
||||
}, names.slice(1));
|
||||
await strip.evaluate((element) => (element.scrollLeft = element.scrollWidth));
|
||||
await page.getByRole("button", { name: "Show Hidden Tabs" }).click();
|
||||
const row = page.getByRole("grid", { name: "Hidden Editor Tabs" }).getByRole("row").filter({ hasText: names[0]! });
|
||||
await expect(row.getByRole("button", { name: "Close Tab", exact: true })).toHaveCount(0);
|
||||
await row.getByRole("button", { name: "Unpin Tab", exact: true }).click();
|
||||
await expect(tab).toHaveCount(1);
|
||||
});
|
||||
|
||||
test("the editor overflow lists clipped tabs and can close or open one without touching visible tabs", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("image controls and metadata stay readable in a narrow editor", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1080, height: 700 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const path = "/dev/acme-api/status.svg";
|
||||
const image =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" width="128" height="96"><rect width="128" height="96"/></svg>';
|
||||
window.__ipc.handlers.fs_read_image = () => "data:image/svg+xml," + encodeURIComponent(image);
|
||||
window.__ipc.handlers.fs_probe = () => ({ size: 4096, binary: false, tooLarge: false });
|
||||
const contributions = "/src/workbench/contributions.ts";
|
||||
const { editorService } = await import(/* @vite-ignore */ contributions);
|
||||
await editorService().openFile(path);
|
||||
});
|
||||
const toolbars = page.getByRole("toolbar", { name: "Image viewer", exact: true });
|
||||
const toolbar = toolbars.last();
|
||||
const zoomIn = toolbar.getByRole("button", { name: "Zoom In", exact: true });
|
||||
const actualSize = toolbar.getByRole("button", { name: "Actual Size", exact: true });
|
||||
const chessboard = toolbar.getByRole("button", { name: "Show Chessboard", exact: true });
|
||||
const showText = toolbar.getByRole("button", { name: "Open as Text", exact: true });
|
||||
const dimensions = toolbar.getByText(/128\s*×\s*96/);
|
||||
await expect(page.getByRole("img", { name: "status.svg", exact: true })).toBeVisible();
|
||||
await expect(dimensions).toBeVisible();
|
||||
const wideHeight = (await toolbar.boundingBox())!.height;
|
||||
|
||||
await page.getByRole("button", { name: "Split Right", exact: true }).click();
|
||||
await expect(toolbars).toHaveCount(2);
|
||||
await page.setViewportSize({ width: 640, height: 570 });
|
||||
expect(await dimensions.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
expect((await toolbar.boundingBox())!.height).toBeGreaterThan(wideHeight);
|
||||
expect((await dimensions.boundingBox())!.y).toBeGreaterThan((await zoomIn.boundingBox())!.y);
|
||||
await expect(dimensions).toHaveCSS("font-size", "13px");
|
||||
await expect(showText).toHaveCSS("white-space", "nowrap");
|
||||
for (const item of [zoomIn, actualSize, chessboard, showText, dimensions]) {
|
||||
await expect(item).toBeInViewport({ ratio: 1 });
|
||||
}
|
||||
await expect(toolbar.getByText("4.0 KB", { exact: true })).toBeVisible();
|
||||
|
||||
await zoomIn.click();
|
||||
await expect(toolbar.getByText("125%", { exact: true })).toBeVisible();
|
||||
await actualSize.click();
|
||||
await expect(toolbar.getByText("100%", { exact: true })).toBeVisible();
|
||||
await chessboard.click();
|
||||
await expect(chessboard).toHaveAttribute("aria-pressed", "false");
|
||||
await showText.click();
|
||||
await expect(page.locator(".cm-content")).toBeVisible();
|
||||
});
|
||||
@@ -83,10 +83,6 @@ test("links independent Gradle roots, runs identical task paths in their own bui
|
||||
});
|
||||
const tasks = tree.getByRole("treeitem", { name: /^assemble\b/ });
|
||||
await expect(tasks).toHaveCount(2);
|
||||
expect(await tasks.allTextContents()).toEqual(["assemble", "assemble"]);
|
||||
for (const task of await tasks.all()) {
|
||||
await expect(task).toHaveAccessibleDescription("Assembles this project");
|
||||
}
|
||||
await page.screenshot({ path: info.outputPath("gradle-two-roots.png"), animations: "disabled" });
|
||||
|
||||
await tasks.nth(0).dblclick();
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function editMacros(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
if (!(await (await import(/* @vite-ignore */ actions)).executeAction("macro.edit"))) throw Error("Edit Macros");
|
||||
});
|
||||
}
|
||||
|
||||
test("Edit Macros keeps a balanced, resizable split for names and recorded steps", async ({ workbench: page }) => {
|
||||
await page.evaluate(async () => {
|
||||
const model = "/src/features/macros/model.ts";
|
||||
const { saveMacro } = await import(/* @vite-ignore */ model);
|
||||
saveMacro("Insert comment", [{ kind: "text", text: "Review this block" }]);
|
||||
saveMacro("Wrap selection", [
|
||||
{ kind: "key", key: "Home" },
|
||||
{ kind: "text", text: "beginProcessingCurrentSelectionImmediately();".repeat(6) },
|
||||
{ kind: "key", key: "End" },
|
||||
]);
|
||||
});
|
||||
await editMacros(page);
|
||||
|
||||
const editor = page.getByRole("dialog", { name: "Edit Macros", exact: true });
|
||||
const macros = editor.getByRole("listbox", { name: "Macros" });
|
||||
const steps = editor.getByRole("list", { name: "Recorded steps" });
|
||||
const options = editor.getByRole("toolbar", { name: "Macros" });
|
||||
const divider = editor.getByRole("separator", { name: "Macros" });
|
||||
const [initial, stepsWidth] = await editor.evaluate((dialog) => [
|
||||
dialog.querySelector('[role="listbox"]')!.getBoundingClientRect().width,
|
||||
dialog.querySelector("ol")!.getBoundingClientRect().width,
|
||||
]);
|
||||
expect(Math.abs(initial - stepsWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(macros).toBeFocused();
|
||||
expect((await steps.boundingBox())!.height).toBeGreaterThan(260);
|
||||
expect((await options.boundingBox())!.y).toBeLessThan((await macros.boundingBox())!.y);
|
||||
|
||||
await macros.getByRole("option", { name: "Wrap selection" }).click();
|
||||
await expect(steps.getByText("Press Home")).toBeVisible();
|
||||
await divider.press("ArrowRight");
|
||||
await expect.poll(async () => (await macros.boundingBox())!.width).toBeGreaterThan(initial + 5);
|
||||
const resized = (await macros.boundingBox())!.width;
|
||||
await editor.locator("[data-dialog-footer]").getByRole("button", { name: "Close" }).click();
|
||||
await editMacros(page);
|
||||
await expect.poll(async () => (await macros.boundingBox())!.width).toBeCloseTo(resized, 0);
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 620 });
|
||||
await macros.getByRole("option", { name: "Wrap selection" }).click();
|
||||
expect(await steps.evaluate((list) => list.scrollWidth - list.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await options.getByRole("button", { name: "Rename Macro" }).click();
|
||||
const rename = page.getByRole("dialog", { name: "Rename Macro", exact: true });
|
||||
await rename.getByRole("textbox").fill("Wrap text");
|
||||
await rename.getByRole("button", { name: "Rename", exact: true }).click();
|
||||
await expect(macros.getByRole("option", { name: "Wrap text" })).toBeVisible();
|
||||
await expect(steps.getByText("Press Home")).toBeVisible();
|
||||
});
|
||||
@@ -1,74 +0,0 @@
|
||||
import type { MavenModel } from "../src/platform/ipc";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const maven: MavenModel = {
|
||||
projects: [
|
||||
{
|
||||
pom: "pom.xml",
|
||||
dir: "",
|
||||
groupId: "dev.acme",
|
||||
artifactId: "billing",
|
||||
version: "1.0.0",
|
||||
packaging: "jar",
|
||||
displayName: "Billing",
|
||||
parent: null,
|
||||
modules: [],
|
||||
aggregated: false,
|
||||
plugins: [
|
||||
{
|
||||
groupId: "org.apache.maven.plugins",
|
||||
artifactId: "maven-surefire-plugin",
|
||||
version: "3.2.5",
|
||||
prefix: "surefire",
|
||||
goals: ["test"],
|
||||
},
|
||||
],
|
||||
dependencies: [],
|
||||
profiles: [],
|
||||
javaVersion: 21,
|
||||
command: "mvn",
|
||||
options: [],
|
||||
env: {},
|
||||
},
|
||||
],
|
||||
profiles: [],
|
||||
syncedAt: 1,
|
||||
stale: false,
|
||||
syncError: null,
|
||||
};
|
||||
|
||||
test("Maven plugin rows give the name priority over coordinates in narrow docks", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (maven) => {
|
||||
window.__ipc.handlers.build_model = () => ({ maven, gradle: [] });
|
||||
const buildModule = "/src/features/build-tools/store.ts";
|
||||
const { loadModel, setExpanded } = await import(/* @vite-ignore */ buildModule);
|
||||
await loadModel();
|
||||
setExpanded("maven", new Set(["mvn:pom.xml", "mvn:pom.xml:plugins"]));
|
||||
const dockModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { showToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ dockModule);
|
||||
showToolWindow("maven", true);
|
||||
setToolWindowSize("right", 190);
|
||||
}, maven);
|
||||
|
||||
const tree = page.getByRole("tree", { name: "Maven projects" });
|
||||
const coordinates = "(org.apache.maven.plugins:maven-surefire-plugin:3.2.5)";
|
||||
const plugin = tree.getByRole("treeitem", { name: `surefire ${coordinates}`, exact: true });
|
||||
const name = plugin.getByText("surefire", { exact: true });
|
||||
const metadata = plugin.getByText(coordinates, { exact: true });
|
||||
await expect(name).toBeVisible();
|
||||
await expect(metadata).toHaveAttribute("title", coordinates);
|
||||
const fit = (el: Element) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
|
||||
};
|
||||
expect(await name.evaluate(fit)).toBe(true);
|
||||
expect(await metadata.evaluate(fit)).toBe(false);
|
||||
expect(await metadata.evaluate((el) => getComputedStyle(el).color)).not.toBe(
|
||||
await name.evaluate((el) => getComputedStyle(el).color),
|
||||
);
|
||||
|
||||
await plugin.locator("[data-tree-toggle]").click();
|
||||
await expect(tree.getByRole("treeitem", { name: "surefire:test", exact: true })).toBeVisible();
|
||||
});
|
||||
+2
-35
@@ -11,7 +11,7 @@ async function openNewBranchDialog(
|
||||
page: Page,
|
||||
from?: string,
|
||||
mergeBase = "1111111",
|
||||
blocked: boolean | string = false,
|
||||
blocked = false,
|
||||
withPrefix = false,
|
||||
) {
|
||||
await stubDesktop(page);
|
||||
@@ -43,10 +43,7 @@ async function openNewBranchDialog(
|
||||
];
|
||||
h.vcs_create_branch = ({ options }) =>
|
||||
blocked && (options as { mode?: string } | null)?.mode === "normal"
|
||||
? {
|
||||
checkout: { kind: "localChanges", files: [typeof blocked === "string" ? blocked : "dirty.txt"] },
|
||||
created: null,
|
||||
}
|
||||
? { checkout: { kind: "localChanges", files: ["dirty.txt"] }, created: null }
|
||||
: { checkout: { kind: "done" }, created: { tip: "2222222", previousTip: null } };
|
||||
h.vcs_merge_base = () => mergeBase;
|
||||
const vcsModule = "/src/features/vcs/store.ts";
|
||||
@@ -154,36 +151,6 @@ for (const [button, mode] of [
|
||||
});
|
||||
}
|
||||
|
||||
test("local changes review keeps file names and checkout choices visible", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1040, height: 740 });
|
||||
const folder = "services/international-payments/regional-settlement/weekly-close/adjustments";
|
||||
const path = `${folder}/ReceiptPolicy.ts`;
|
||||
const { dialog, input } = await openNewBranchDialog(page, "2".repeat(40), "1111111", path);
|
||||
await input.fill("topic");
|
||||
await dialog.getByRole("button", { name: "Create", exact: true }).click();
|
||||
const review = page.getByRole("dialog", { name: "Git Checkout Problem" });
|
||||
const force = review.getByRole("button", { name: "Force Checkout", exact: true });
|
||||
const smart = review.getByRole("button", { name: "Smart Checkout", exact: true });
|
||||
const cancel = review.getByRole("button", { name: "Don't Checkout", exact: true });
|
||||
await expect(force).toBeVisible();
|
||||
expect((await force.boundingBox())!.x - (await review.boundingBox())!.x).toBeLessThan(24);
|
||||
|
||||
await page.setViewportSize({ width: 420, height: 480 });
|
||||
const tree = review.getByRole("tree", { name: "Changed files" });
|
||||
const row = tree.getByRole("treeitem", { name: `ReceiptPolicy.ts ${folder}`, exact: true });
|
||||
await expect(row.getByTitle(path, { exact: true })).toBeVisible();
|
||||
const file = row.getByText("ReceiptPolicy.ts", { exact: true });
|
||||
await expect(file).toBeInViewport({ ratio: 1 });
|
||||
expect(await file.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(row.getByText(folder, { exact: true })).toHaveCSS("font-size", "12px");
|
||||
const restoreHint = review.getByText(/Smart Checkout .* your changes and restores them/);
|
||||
expect((await restoreHint.boundingBox())!.y).toBeLessThan((await tree.boundingBox())!.y);
|
||||
for (const button of [force, smart, cancel]) await expect(button).toBeInViewport({ ratio: 1 });
|
||||
await cancel.click();
|
||||
await expect(review).toBeHidden();
|
||||
expect(await ipcCalls(page, "vcs_create_branch")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("pasted text has its spaces replaced", async ({ workbench: page }) => {
|
||||
const { dialog, input } = await openNewBranchDialog(page);
|
||||
await input.fill("");
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("fits notification body and actions below the dismiss button in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 420, height: 540 });
|
||||
const title = "Validation failed for the catalog service";
|
||||
const body = "The build stopped while checking the catalog response type.";
|
||||
const action = "recheckCatalogServiceResponsePayloadAfterRegeneratingTypesForDevelopment";
|
||||
await page.evaluate(
|
||||
async ({ title, body, action }) => {
|
||||
const servicePath = "/src/workbench/contributions.ts";
|
||||
const { notifications } = await import(/* @vite-ignore */ servicePath);
|
||||
notifications().notify({
|
||||
level: "error",
|
||||
title,
|
||||
body,
|
||||
actions: [{ label: action, run: () => document.body.setAttribute("data-validation-retried", "true") }],
|
||||
});
|
||||
},
|
||||
{ title, body, action },
|
||||
);
|
||||
|
||||
const balloon = page.getByRole("alert").filter({ hasText: title });
|
||||
const message = balloon.getByText(body, { exact: true });
|
||||
const dismiss = balloon.getByRole("button", { name: "Dismiss", exact: true });
|
||||
const retry = balloon.getByRole("button", { name: action, exact: true });
|
||||
await expect(balloon).toBeInViewport({ ratio: 1 });
|
||||
const [messageBox, dismissBox] = await Promise.all([message.boundingBox(), dismiss.boundingBox()]);
|
||||
expect(messageBox!.y).toBeGreaterThanOrEqual(dismissBox!.y + dismissBox!.height);
|
||||
expect(messageBox!.x + messageBox!.width).toBeGreaterThanOrEqual(dismissBox!.x + dismissBox!.width - 1);
|
||||
expect(await retry.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await retry.click();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-validation-retried", "true");
|
||||
await expect(balloon).toBeHidden();
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Quick Evaluate and hover keep value previews usable in a narrow editor", async ({ workbench: page }) => {
|
||||
test("Quick Evaluate opens an object tree that fits the editor and returns focus on Escape", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 445, height: 500 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
@@ -17,9 +19,7 @@ test("Quick Evaluate and hover keep value previews usable in a narrow editor", a
|
||||
h.fs_probe = () => ({ size: 48, binary: false, tooLarge: false });
|
||||
h.fs_read_text = () => "summary = {}\nsubtotal = 42\n";
|
||||
h.debug_evaluate_in = ({ expression }) =>
|
||||
expression === "summary"
|
||||
? value("summary", `{'audit': '${"Regional settlement totals ".repeat(8)}'}`, "dict", 101)
|
||||
: value("subtotal", "42", "int");
|
||||
expression === "summary" ? value("summary", "{...}", "dict", 101) : value("subtotal", "42", "int");
|
||||
h.debug_variables = ({ reference }) =>
|
||||
reference === 101
|
||||
? [value("audit", "{...}", "dict", 102), value("total", "47.74", "float")]
|
||||
@@ -81,59 +81,8 @@ test("Quick Evaluate and hover keep value previews usable in a narrow editor", a
|
||||
await evaluate(2);
|
||||
await expect(hint.getByRole("tree")).toHaveCount(0);
|
||||
await expect(hint).toHaveText(/subtotal\s*=\s*42/);
|
||||
const scalar = hint.locator("[class*='_valueTooltip_']");
|
||||
const uiFont = await page.locator("body").evaluate((el) => getComputedStyle(el).fontFamily);
|
||||
await expect(scalar).toHaveCSS("font-family", uiFont);
|
||||
await expect(scalar).toHaveCSS("font-size", "13px");
|
||||
await expect(scalar).toHaveCSS("font-weight", "700");
|
||||
await expect(scalar.locator(".cm-openidea-icon")).toHaveCount(1);
|
||||
await content.press("Escape");
|
||||
await expect(hint).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 620, height: 480 });
|
||||
await page.evaluate(async () => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const servicesModule = "/src/workbench/contributions.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
|
||||
moveToolWindow("project", "left");
|
||||
setToolWindowSize("left", 220);
|
||||
toolWindowService().show("project", false);
|
||||
});
|
||||
await expect.poll(async () => (await editor.boundingBox())!.x).toBeGreaterThan(160);
|
||||
const position = await content.evaluate((el) => {
|
||||
const { view } = (el as HTMLElement & { cmTile: { view: EditorView } }).cmTile;
|
||||
return view.coordsAtPos(view.state.doc.line(1).from + 2);
|
||||
});
|
||||
await page.mouse.move(position!.left, (position!.top + position!.bottom) / 2);
|
||||
const hover = page.locator(".cm-tooltip-hover").locator("[class*='_valueTooltip_']");
|
||||
const expand = hover.getByRole("button", { name: "Expand value" });
|
||||
await expect(hover).toContainText("Regional settlement totals");
|
||||
await expect(hover).toHaveCSS("font-family", uiFont);
|
||||
const summary = hover.locator("[class*='_valueText_']");
|
||||
const textBox = (await summary.boundingBox())!;
|
||||
const controlBox = (await expand.boundingBox())!;
|
||||
const iconBox = (await hover.locator(".cm-openidea-icon").boundingBox())!;
|
||||
expect(textBox.height).toBeGreaterThan(20);
|
||||
expect(Math.abs(controlBox.y - iconBox.y)).toBeLessThan(1);
|
||||
expect(textBox.x).toBeGreaterThanOrEqual(iconBox.x + iconBox.width);
|
||||
const fitsEditor = async () => {
|
||||
const tooltip = await hover.boundingBox();
|
||||
const pane = (await editor.boundingBox())!;
|
||||
return !!tooltip && tooltip.x >= pane.x - 1 && tooltip.x + tooltip.width <= pane.x + pane.width + 1;
|
||||
};
|
||||
await expect.poll(fitsEditor).toBe(true);
|
||||
await page.setViewportSize({ width: 555, height: 480 });
|
||||
await expect.poll(fitsEditor).toBe(true);
|
||||
await expand.click();
|
||||
const pinned = hint.getByRole("tree", { name: "summary" });
|
||||
await expect(pinned).toBeFocused();
|
||||
await pinned.press("Escape");
|
||||
await expect(content).toBeFocused();
|
||||
const calls = await ipcCalls(page, "debug_evaluate_in");
|
||||
expect(calls.filter((call) => call.context === "watch")).toEqual([
|
||||
expect(await ipcCalls(page, "debug_evaluate_in")).toEqual([
|
||||
{ session: 91, frameId: 11, expression: "summary", context: "watch" },
|
||||
{ session: 91, frameId: 11, expression: "subtotal", context: "watch" },
|
||||
]);
|
||||
expect(calls).toContainEqual({ session: 91, frameId: 11, expression: "summary", context: "hover" });
|
||||
});
|
||||
@@ -1,75 +0,0 @@
|
||||
import type { SearchQuery } from "../src/bindings";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Replace All keeps both values readable and the actions visible", async ({ workbench: page }) => {
|
||||
const pattern = `LEGACY_${"MONTH_END_RECONCILIATION_INPUT_".repeat(15)}END`;
|
||||
const replacement = `ACTIVE_${"MONTH_END_RECONCILIATION_OUTPUT_".repeat(18)}END`;
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate((pattern) => {
|
||||
window.__ipc.handlers.search_validate = () => null;
|
||||
window.__ipc.handlers.search_start = ({ query, onEvent }) => {
|
||||
if ((query as SearchQuery).pattern !== pattern) return null;
|
||||
setTimeout(() => {
|
||||
for (const relPath of ["invoice.txt", "receipt.txt"]) {
|
||||
window.__ipc.send(onEvent, {
|
||||
type: "file",
|
||||
file: {
|
||||
path: `/dev/acme-api/${relPath}`,
|
||||
relPath,
|
||||
matches: [{ line: 0, text: pattern, ranges: [[0, pattern.length]], textOffset: 0 }],
|
||||
},
|
||||
});
|
||||
}
|
||||
window.__ipc.send(onEvent, {
|
||||
type: "done",
|
||||
summary: { files: 2, matches: 2, limitHit: false, cancelled: false, elapsedMs: 1 },
|
||||
});
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
}, pattern);
|
||||
await page.keyboard.press("Meta+Shift+r");
|
||||
const popup = page.getByRole("dialog", { name: "Replace in Files", exact: true });
|
||||
await popup.getByRole("textbox", { name: "Text to find", exact: true }).fill(pattern);
|
||||
const replacementInput = popup.getByRole("textbox", { name: "Replace with", exact: true });
|
||||
await replacementInput.fill(replacement);
|
||||
await expect(popup.getByRole("listbox", { name: "Matches" }).getByRole("option")).toHaveCount(2);
|
||||
await page.setViewportSize({ width: 440, height: 520 });
|
||||
await popup.getByRole("button", { name: "Replace All", exact: true }).click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Replace All", exact: true });
|
||||
const findText = dialog.getByRole("region", { name: "Text to find", exact: true });
|
||||
const replaceText = dialog.getByRole("region", { name: "Replace with", exact: true });
|
||||
const replace = dialog.getByRole("button", { name: "Replace", exact: true });
|
||||
const cancel = dialog.getByRole("button", { name: "Cancel", exact: true });
|
||||
await expect(findText).toHaveText(pattern);
|
||||
await expect(replaceText).toHaveText(replacement);
|
||||
await expect(dialog.getByText("Replace 2 occurrences in 2 files?", { exact: true })).toBeVisible();
|
||||
const bottom = (await replace.boundingBox())!.y;
|
||||
for (const item of [findText, replaceText]) {
|
||||
await expect(item).toHaveCSS("font-size", "13px");
|
||||
expect(await item.evaluate((el) => el.scrollHeight > el.clientHeight && el.scrollWidth === el.clientWidth)).toBe(
|
||||
true,
|
||||
);
|
||||
await item.focus();
|
||||
await page.keyboard.press("End");
|
||||
await expect.poll(() => item.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
}
|
||||
expect((await replace.boundingBox())!.y).toBeCloseTo(bottom, 0);
|
||||
await expect(replace).toBeInViewport({ ratio: 1 });
|
||||
await expect(cancel).toBeInViewport({ ratio: 1 });
|
||||
await cancel.click();
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await replacementInput.fill("");
|
||||
await popup.getByRole("button", { name: "Open in Find Window", exact: true }).click();
|
||||
const findWindow = page.getByRole("region", { name: "Find", exact: true });
|
||||
await findWindow.getByRole("button", { name: "Replace All", exact: true }).click();
|
||||
await expect(findText).toHaveText(pattern);
|
||||
await expect(replaceText).toHaveText("Empty text");
|
||||
await cancel.click();
|
||||
expect(await ipcCalls(page, "replace_in_files")).toHaveLength(0);
|
||||
});
|
||||
@@ -581,54 +581,3 @@ test("CMake builds the selected target in Build before starting only the applica
|
||||
await expect(run.getByRole("tab", { name: "hello [Release, release]" })).toBeVisible();
|
||||
await expect(run.getByText("COMPILER_OUTPUT", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("test report export separates the format and destination in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 410, height: 500 });
|
||||
await stubRun(
|
||||
page,
|
||||
[
|
||||
{
|
||||
kind: "stdout",
|
||||
text: '{"Package":"example.com/checkout","Action":"pass","Test":"TestReceipt","Elapsed":0.1}\n',
|
||||
},
|
||||
],
|
||||
0,
|
||||
{ id: "go:report-tests", name: "Checkout tests", kind: "go", command: "go", args: ["test", "-json"], isTest: true },
|
||||
);
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.fs_entry_kind = () => {
|
||||
throw { kind: "NotFound", message: "Not found" };
|
||||
};
|
||||
window.__ipc.handlers.fs_create_file_bytes = () => null;
|
||||
});
|
||||
|
||||
await page.keyboard.press("Control+r");
|
||||
const results = page.getByRole("toolbar", { name: "Test results" });
|
||||
await results.getByRole("button", { name: "More Actions" }).click();
|
||||
const exportItem = page.getByRole("menuitem", { name: "Export Test Results…" });
|
||||
await expect(exportItem).toBeEnabled();
|
||||
await exportItem.click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Export Test Results" });
|
||||
const html = dialog.getByRole("radio", { name: "HTML", exact: true });
|
||||
const xml = dialog.getByRole("radio", { name: "XML", exact: true });
|
||||
await expect(html).toBeVisible();
|
||||
expect((await xml.boundingBox())!.y).toBeGreaterThan((await html.boundingBox())!.y);
|
||||
const file = dialog.getByLabel("File name", { exact: true });
|
||||
const folder = dialog.getByLabel("Folder", { exact: true });
|
||||
const browse = dialog.getByRole("button", { name: "Browse…" });
|
||||
await expect(file).toBeFocused();
|
||||
await expect(file).toHaveValue("Test Results - Checkout tests.html");
|
||||
await expect(folder).toHaveValue("/dev/acme-api");
|
||||
await expect(browse).toBeInViewport({ ratio: 1 });
|
||||
expect((await folder.boundingBox())!.width).toBeGreaterThan(180);
|
||||
await file.fill("receipts.html");
|
||||
await folder.fill("reports");
|
||||
await xml.check();
|
||||
await expect(file).toHaveValue("receipts.xml");
|
||||
await expect(dialog.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled();
|
||||
await dialog.getByRole("button", { name: "OK", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
const [write] = await ipcCalls(page, "fs_create_file_bytes");
|
||||
expect(write).toMatchObject({ path: "/dev/acme-api/reports/receipts.xml" });
|
||||
});
|
||||
+20
-152
@@ -1,145 +1,39 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import type { BeforeLaunchTask } from "../src/bindings";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("expands VM options beside the field and returns edited text to the configuration", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const original = "-Xmx512m\n-Ddemo.endpoint=https://example.test/" + "long-segment/".repeat(12);
|
||||
await page.evaluate(async (vmOptions) => {
|
||||
async function openConfigurations(page: Page, target?: string) {
|
||||
await page.evaluate(async (target) => {
|
||||
const path = "/src/features/run/store.ts";
|
||||
const { useRun } = await import(/* @vite-ignore */ path);
|
||||
const base = {
|
||||
kind: "shell",
|
||||
command: "/Users/developer/projects/acme/services/payments/scripts/start-development-server",
|
||||
args: ["--watch"],
|
||||
cwd: "/Users/developer/projects/acme/services/payments",
|
||||
env: { NODE_ENV: "development" },
|
||||
detected: false,
|
||||
isTest: false,
|
||||
debugAdapter: null,
|
||||
};
|
||||
useRun.setState({
|
||||
configs: [
|
||||
{
|
||||
id: "layout:jvm",
|
||||
name: "Catalog service",
|
||||
kind: "application",
|
||||
command: "java",
|
||||
args: ["example.Catalog"],
|
||||
params: { mainClass: "example.Catalog", vmOptions },
|
||||
env: {},
|
||||
cwd: null,
|
||||
detected: false,
|
||||
isTest: false,
|
||||
debugAdapter: "java-debug",
|
||||
...base,
|
||||
id: "layout:app",
|
||||
name: "Payments development server",
|
||||
target,
|
||||
beforeLaunch: [{ kind: "run", target: "layout:prepare" }],
|
||||
},
|
||||
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
|
||||
],
|
||||
editTarget: "layout:jvm",
|
||||
selectedId: "layout:app",
|
||||
loaded: true,
|
||||
editorOpen: true,
|
||||
});
|
||||
}, original);
|
||||
|
||||
const config = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
const field = config.getByRole("textbox", { name: "VM options", exact: true });
|
||||
const expanded = page.getByRole("dialog", { name: "VM options", exact: true });
|
||||
const editor = expanded.getByRole("textbox", { name: "VM options", exact: true });
|
||||
for (const width of [1100, 560]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
await field.scrollIntoViewIfNeeded();
|
||||
await field.press("Shift+Enter");
|
||||
await expect(editor).toBeFocused();
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const source = (await field.boundingBox())!;
|
||||
const popup = (await expanded.boundingBox())!;
|
||||
const gap = Math.min(Math.abs(popup.y - source.y - source.height), Math.abs(source.y - popup.y - popup.height));
|
||||
return popup.x >= 0 && popup.x + popup.width <= width && gap <= 6;
|
||||
})
|
||||
.toBe(true);
|
||||
await expect.poll(() => editor.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeGreaterThan(0);
|
||||
await editor.fill("-Xmx1g");
|
||||
await editor.press("Escape");
|
||||
await expect(expanded).toBeHidden();
|
||||
await expect(field).toBeFocused();
|
||||
await expect(field).toHaveValue(original);
|
||||
}
|
||||
|
||||
const expand = config.getByRole("button", { name: "Expand (⇧⏎)", exact: true });
|
||||
await expand.click();
|
||||
await expect(editor).toBeFocused();
|
||||
await editor.fill(original + "\n-Ddemo.mode=local");
|
||||
await editor.press("Control+Enter");
|
||||
await expect(expanded).toBeHidden();
|
||||
await expect(field).toHaveValue(original + "\n-Ddemo.mode=local");
|
||||
});
|
||||
|
||||
async function openConfigurations(page: Page, target?: string, beforeLaunch?: BeforeLaunchTask[]) {
|
||||
await page.evaluate(
|
||||
async ({ target, beforeLaunch }) => {
|
||||
const path = "/src/features/run/store.ts";
|
||||
const { useRun } = await import(/* @vite-ignore */ path);
|
||||
const base = {
|
||||
kind: "shell",
|
||||
command: "/Users/developer/projects/acme/services/payments/scripts/start-development-server",
|
||||
args: ["--watch"],
|
||||
cwd: "/Users/developer/projects/acme/services/payments",
|
||||
env: { NODE_ENV: "development" },
|
||||
detected: false,
|
||||
isTest: false,
|
||||
debugAdapter: null,
|
||||
};
|
||||
useRun.setState({
|
||||
configs: [
|
||||
{
|
||||
...base,
|
||||
id: "layout:app",
|
||||
name: "Payments development server",
|
||||
target,
|
||||
beforeLaunch: beforeLaunch ?? [{ kind: "run", target: "layout:prepare" }],
|
||||
},
|
||||
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
|
||||
],
|
||||
selectedId: "layout:app",
|
||||
loaded: true,
|
||||
editorOpen: true,
|
||||
});
|
||||
},
|
||||
{ target, beforeLaunch },
|
||||
);
|
||||
}, target);
|
||||
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true })).toBeVisible();
|
||||
}
|
||||
|
||||
test("before-launch tasks wrap as ordered tags and keep their edit controls", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1150, height: 820 });
|
||||
await openConfigurations(page, undefined, [
|
||||
{ kind: "build" },
|
||||
{ kind: "buildArtifacts" },
|
||||
{ kind: "command", target: "make generate" },
|
||||
]);
|
||||
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
const tasks = dialog.getByRole("list", { name: "Before launch tasks", exact: true });
|
||||
const build = tasks.getByRole("button", { name: "1. Build Project", exact: true });
|
||||
const artifacts = tasks.getByRole("button", { name: "2. Build Artifacts", exact: true });
|
||||
await tasks.scrollIntoViewIfNeeded();
|
||||
await expect(build).toBeVisible();
|
||||
expect((await build.boundingBox())!.y).toBeCloseTo((await artifacts.boundingBox())!.y, 0);
|
||||
await expect(build).toHaveCSS("font-size", "13px");
|
||||
|
||||
await page.setViewportSize({ width: 520, height: 820 });
|
||||
await expect.poll(() => tasks.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
const command = tasks.getByRole("textbox", { name: "Before launch command 3" });
|
||||
expect((await command.boundingBox())!.y).toBeGreaterThan((await build.boundingBox())!.y + 20);
|
||||
await command.fill("make report");
|
||||
|
||||
await build.press("Enter");
|
||||
const actions = page.getByRole("menu", { name: "Task Actions", exact: true });
|
||||
const moveDown = actions.getByRole("menuitem", { name: "Move Down", exact: true });
|
||||
await expect(moveDown).toBeVisible();
|
||||
await moveDown.click();
|
||||
await expect(tasks.getByRole("button", { name: "1. Build Artifacts", exact: true })).toBeVisible();
|
||||
const moved = tasks.getByRole("listitem").filter({
|
||||
has: page.getByRole("button", { name: "2. Build Project", exact: true }),
|
||||
});
|
||||
await moved.getByRole("button", { name: "Remove Task" }).click();
|
||||
await expect(tasks.getByRole("textbox", { name: "Before launch command 2" })).toHaveValue("make report");
|
||||
|
||||
await tasks.getByRole("button", { name: "Add task", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "Build Project", exact: true }).click();
|
||||
await expect(tasks.getByRole("button", { name: "3. Build Project", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("long run target names leave room for configuration names in the sidebar", async ({ workbench: page }) => {
|
||||
const target = "payments-development-shared-staging-runner-west";
|
||||
await openConfigurations(page, target);
|
||||
@@ -161,32 +55,6 @@ test("long run target names leave room for configuration names in the sidebar",
|
||||
await expect(dialog.getByRole("textbox", { name: "Name", exact: true })).toHaveValue("Payments development server");
|
||||
});
|
||||
|
||||
test("the configuration type list scrolls below its search field in a short window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 780, height: 370 });
|
||||
await openConfigurations(page);
|
||||
const dialog = page.getByRole("dialog", { name: "Run/Debug Configurations", exact: true });
|
||||
await dialog.getByRole("button", { name: "Add New Configuration", exact: true }).click();
|
||||
const chooser = page.getByRole("dialog", { name: "Add New Configuration", exact: true });
|
||||
const search = chooser.getByRole("textbox", { name: "Search configuration types" });
|
||||
const list = chooser.getByRole("listbox", { name: "Configuration types" });
|
||||
await expect(search).toBeFocused();
|
||||
expect(await chooser.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeLessThanOrEqual(1);
|
||||
expect(await list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(0);
|
||||
|
||||
await search.press("End");
|
||||
const active = list.getByRole("option", { selected: true });
|
||||
await expect(active).toBeInViewport({ ratio: 0.98 });
|
||||
expect(await list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
await expect(active.locator("svg")).toHaveAttribute("width", "16");
|
||||
await expect(search).toBeInViewport({ ratio: 1 });
|
||||
|
||||
await search.fill("Tomcat");
|
||||
await expect(list.getByRole("option", { name: "Tomcat Server", selected: true })).toBeVisible();
|
||||
await search.press("Enter");
|
||||
await expect(chooser).toBeHidden();
|
||||
await expect(dialog.getByRole("tab", { name: "Server", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("run configuration sidebar resizes with mouse and keyboard and remembers the layout", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const prefix = "reconcile-regional-inventory-and-rebuild-order-settlement-cache-for-warehouse-";
|
||||
const east = prefix + "east-stage";
|
||||
const west = prefix + "west-stage";
|
||||
const content = JSON.stringify(
|
||||
{ name: "warehouse-tools", scripts: { [east]: "node east.js", [west]: "node west.js", build: "node build.js" } },
|
||||
null,
|
||||
2,
|
||||
);
|
||||
|
||||
test("the npm gutter keeps distinct ends of long names and runs the selected script", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 440, height: 520 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (text) => {
|
||||
const backendPath = "/src/editor/core/backend.ts";
|
||||
const servicePath = "/src/workbench/contributions.ts";
|
||||
const { docBackend } = await import(/* @vite-ignore */ backendPath);
|
||||
const { editorService } = await import(/* @vite-ignore */ servicePath);
|
||||
const path = "/dev/acme-api/package.json";
|
||||
docBackend().files.set(path, text);
|
||||
const handlers = window.__ipc.handlers;
|
||||
handlers.fs_probe = () => ({ size: text.length, binary: false, tooLarge: false });
|
||||
handlers.fs_read_text = ({ path }) => docBackend().files.get(String(path)) ?? "";
|
||||
handlers.fs_read_dir = () => [];
|
||||
handlers.run_configs = () => [];
|
||||
handlers.run_start = ({ config }) => ({
|
||||
id: 7,
|
||||
configId: (config as { id: string }).id,
|
||||
name: (config as { name: string }).name,
|
||||
pid: 4242,
|
||||
running: true,
|
||||
pty: false,
|
||||
});
|
||||
await editorService().openFile(path);
|
||||
}, content);
|
||||
const editor = page.locator(".cm-editor");
|
||||
const menu = page.getByRole("menu", { name: "Context menu" });
|
||||
for (const name of [east, west]) {
|
||||
await editor.getByTitle("Run '" + name + "'", { exact: true }).click();
|
||||
const label = "Run 'npm run " + name + "'";
|
||||
const run = menu.getByRole("menuitem", { name: label, exact: true });
|
||||
const end = run.getByText(label.slice(-12), { exact: true });
|
||||
await expect(end).toBeVisible();
|
||||
await expect(end.locator("..")).toHaveAttribute("title", label);
|
||||
expect(await end.evaluate((node) => node.clientWidth >= node.scrollWidth)).toBe(true);
|
||||
const start = end.locator("..").locator(":scope > span").first();
|
||||
expect(await start.evaluate((node) => node.clientWidth < node.scrollWidth)).toBe(true);
|
||||
await expect(start).toHaveCSS("text-overflow", "ellipsis");
|
||||
const titleUnderPointer = await start.evaluate((node) => {
|
||||
const { x, y, width, height } = node.getBoundingClientRect();
|
||||
return document.elementFromPoint(x + width / 2, y + height / 2)?.getAttribute("title");
|
||||
});
|
||||
expect(titleUnderPointer).toBe(label);
|
||||
await expect(run).toBeFocused();
|
||||
if (name === east) await run.press("Escape");
|
||||
else await run.press("Enter");
|
||||
await expect(menu).toBeHidden();
|
||||
}
|
||||
await expect
|
||||
.poll(async () => ipcCalls(page, "run_start"))
|
||||
.toMatchObject([{ config: { args: ["run", west], kind: "npm" } }]);
|
||||
});
|
||||
@@ -1,64 +1,4 @@
|
||||
import { doubleShift, expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Search Everywhere keeps line numbers visible beside long Text result filenames", async ({ workbench: page }) => {
|
||||
const relPath = "config/InternationalSettlementReconciliationEndpointsForStagingEnvironments.ts";
|
||||
const query = "settlementEndpoint";
|
||||
const text = `const ${query} = "/staging/settlement";`;
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
({ relPath, text, query }) => {
|
||||
window.__ipc.handlers.search_start = (args) => {
|
||||
setTimeout(() => {
|
||||
const matches = [12344, 12345].map((line) => ({
|
||||
line,
|
||||
text,
|
||||
ranges: [[6, 6 + query.length]],
|
||||
textOffset: 0,
|
||||
}));
|
||||
window.__ipc.send(args.onEvent, {
|
||||
type: "file",
|
||||
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
|
||||
});
|
||||
window.__ipc.send(args.onEvent, {
|
||||
type: "done",
|
||||
summary: { files: 1, matches: 2, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
});
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
},
|
||||
{ relPath, text, query },
|
||||
);
|
||||
|
||||
await doubleShift(page);
|
||||
const dialog = page.getByRole("dialog", { name: "Search Everywhere" });
|
||||
await dialog.getByRole("tab", { name: "Text", exact: true }).click();
|
||||
const search = dialog.getByRole("combobox", { name: "Search query" });
|
||||
await search.fill(query);
|
||||
const rows = dialog.getByRole("option");
|
||||
await expect(rows).toHaveCount(2);
|
||||
for (const width of [920, 440]) {
|
||||
await page.setViewportSize({ width, height: 640 });
|
||||
for (const line of [12345, 12346]) {
|
||||
const row = rows.filter({ hasText: String(line) });
|
||||
await expect(row.locator("mark")).toHaveText(query);
|
||||
expect(
|
||||
await row.evaluate((el) => {
|
||||
const location = el.lastElementChild!;
|
||||
const lineText = location.lastChild!;
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(lineText);
|
||||
const bounds = range.getBoundingClientRect();
|
||||
const clip = location.getBoundingClientRect();
|
||||
return bounds.width > 0 && bounds.left >= clip.left && bounds.right <= clip.right + 1;
|
||||
}),
|
||||
).toBe(true);
|
||||
await expect(row.getByText(relPath.split("/").at(-1)!, { exact: true })).toHaveAttribute("title", relPath);
|
||||
}
|
||||
}
|
||||
await search.press("ArrowDown");
|
||||
await expect(rows.nth(1)).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ async function run(page: Page, id: string) {
|
||||
}, id);
|
||||
}
|
||||
|
||||
async function stubFindMatches(page: Page, firstPath = LONG_RESULT_PATH) {
|
||||
async function stubFindMatches(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate((longPath) => {
|
||||
window.__ipc.handlers.search_validate = () => null;
|
||||
@@ -39,7 +39,7 @@ async function stubFindMatches(page: Page, firstPath = LONG_RESULT_PATH) {
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
}, firstPath);
|
||||
}, LONG_RESULT_PATH);
|
||||
}
|
||||
|
||||
async function expectControlsFit(page: Page) {
|
||||
@@ -205,29 +205,3 @@ test("Find in Files prioritizes the preview and remembers an adjusted split", as
|
||||
await expect(handle).toBeAttached();
|
||||
await expect.poll(resultsShare).toBeCloseTo(adjusted, 2);
|
||||
});
|
||||
|
||||
test("Find in Files keeps the file and its parent folder visible in the preview caption", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 400, height: 570 });
|
||||
const prefix = "config/generated/regional-integrations/sandbox/development/notifications";
|
||||
const name = "RegionalLedgerSettings.txt";
|
||||
const path = `${prefix}/runtime/${name}`;
|
||||
await stubFindMatches(page, path);
|
||||
await run(page, "find.inPath");
|
||||
const dialog = page.getByRole("dialog", { name: "Find in Files" });
|
||||
const search = dialog.getByPlaceholder("Search");
|
||||
await search.fill("http://localhost:8080");
|
||||
const preview = dialog.locator("[data-panel][id=preview]");
|
||||
const caption = preview.getByTitle(path, { exact: true });
|
||||
const folder = caption.getByText("/runtime", { exact: true });
|
||||
const beginning = caption.getByText(prefix, { exact: true });
|
||||
await expect(caption.getByText(name, { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(folder).toBeInViewport({ ratio: 1 });
|
||||
await expect(folder).toHaveCSS("font-size", "13px");
|
||||
expect(await beginning.evaluate((el) => el.scrollWidth > el.clientWidth)).toBe(true);
|
||||
expect(await folder.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
await search.press("ArrowDown");
|
||||
await search.press("ArrowDown");
|
||||
await expect(preview.getByTitle("config/endpoint-1.txt", { exact: true })).toContainText("endpoint-1.txt");
|
||||
});
|
||||
@@ -1,66 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Find in Files keeps the scope list and pattern editor usable in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
const longName = "Regional settlement reconciliation sources for month-end audit and publication";
|
||||
await page.evaluate(async (longName) => {
|
||||
const search = "/src/platform/search.ts";
|
||||
const { saveCustomScopes } = await import(/* @vite-ignore */ search);
|
||||
saveCustomScopes(
|
||||
Array.from({ length: 26 }, (_, i) => ({
|
||||
name: i ? `Reconciliation scope ${i + 1}` : longName,
|
||||
pattern: i ? `file:src/scope-${i + 1}//*` : "file:src/reconciliation//*",
|
||||
})),
|
||||
);
|
||||
}, longName);
|
||||
await page.keyboard.press("Meta+Shift+F");
|
||||
const find = page.getByRole("dialog", { name: "Find in Files", exact: true });
|
||||
await find.getByRole("tab", { name: "Scope", exact: true }).click();
|
||||
const openScopes = find.getByRole("button", { name: "Edit Scopes…", exact: true });
|
||||
await openScopes.click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Scopes", exact: true });
|
||||
const list = dialog.getByRole("list", { name: "Scopes", exact: true });
|
||||
const name = dialog.getByRole("textbox", { name: "Name:", exact: true });
|
||||
const pattern = dialog.getByRole("textbox", { name: "Pattern:", exact: true });
|
||||
await expect(pattern).toHaveValue("file:src/reconciliation//*");
|
||||
expect(await list.evaluate((el) => el.scrollHeight - el.clientHeight)).toBeGreaterThan(100);
|
||||
await expect(list.getByRole("button", { name: longName })).toHaveAttribute("title", longName);
|
||||
expect((await list.boundingBox())!.x).toBeLessThan((await name.boundingBox())!.x);
|
||||
|
||||
await page.setViewportSize({ width: 460, height: 530 });
|
||||
// The dialog relays out over a few frames after the resize; measure once it has settled.
|
||||
let fields = (await pattern.boundingBox())!;
|
||||
await expect(async () => {
|
||||
const previous = fields.y;
|
||||
await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))));
|
||||
fields = (await pattern.boundingBox())!;
|
||||
expect(fields.y).toBe(previous);
|
||||
}).toPass();
|
||||
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", "vcs.log"]) {
|
||||
for (const id of ["appearance", "editor.font", "general", "general.httpProxy"]) {
|
||||
await selectPage(page, id);
|
||||
const body = page.locator("[class*='pageBody']");
|
||||
for (const width of [1000, 784, 640, 520]) {
|
||||
@@ -108,31 +108,6 @@ test("keeps Open project in options within narrow System Settings", async ({ wor
|
||||
expect(overflow).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
test("Git Log settings group display and column options with aligned checkboxes", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await selectPage(page, "vcs.log");
|
||||
const view = dialog.getByRole("region", { name: "View Options" });
|
||||
const columns = dialog.getByRole("region", { name: "Visible columns" });
|
||||
const tagNames = view.getByRole("checkbox", { name: "Show tag names" });
|
||||
const hash = columns.getByRole("checkbox", { name: "Hash" });
|
||||
await expect(view.getByRole("checkbox")).toHaveCount(5);
|
||||
await expect(columns.getByRole("checkbox")).toHaveCount(4);
|
||||
|
||||
for (const width of [1000, 520]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
// Read both rows together once the dialog has finished opening and relaid out.
|
||||
await expect
|
||||
.poll(async () => Math.abs((await tagNames.boundingBox())!.x - (await hash.boundingBox())!.x))
|
||||
.toBeLessThan(0.5);
|
||||
}
|
||||
|
||||
await expect(hash).not.toBeChecked();
|
||||
await hash.focus();
|
||||
await page.keyboard.press("Space");
|
||||
await expect(hash).toBeChecked();
|
||||
});
|
||||
|
||||
test("settings sidebar resizes with mouse and keyboard and remembers its width", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Settings aligns search results with their parent pages and honors smaller tree indents", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = dialog.getByRole("textbox", { name: "Search settings" });
|
||||
const tree = dialog.getByRole("tree", { name: "Settings pages" });
|
||||
await search.fill("Language Defaults");
|
||||
|
||||
const editor = tree.getByRole("treeitem", { name: "Editor", exact: true });
|
||||
const scheme = tree.getByRole("treeitem", { name: "Color Scheme", exact: true });
|
||||
const defaults = tree.getByRole("treeitem", { name: "Language Defaults", exact: true });
|
||||
await expect(defaults).toHaveAttribute("aria-selected", "true");
|
||||
await expect(defaults.locator("mark")).toHaveText(["Language", "Defaults"]);
|
||||
|
||||
const insets = () =>
|
||||
Promise.all(
|
||||
[editor, scheme, defaults].map((row) =>
|
||||
row.locator(":scope > span:last-child").evaluate((label) => {
|
||||
const left = label.closest('[role="tree"]')!.getBoundingClientRect().left;
|
||||
return Math.round(label.getBoundingClientRect().left - left);
|
||||
}),
|
||||
),
|
||||
);
|
||||
await expect.poll(insets).toEqual([28, 44, 60]);
|
||||
await page.setViewportSize({ width: 580, height: 720 });
|
||||
await expect.poll(insets).toEqual([28, 44, 60]);
|
||||
await page.evaluate(() => document.documentElement.style.setProperty("--tree-indent", "12px"));
|
||||
await expect.poll(insets).toEqual([28, 40, 52]);
|
||||
|
||||
await search.press("ArrowUp");
|
||||
await expect(scheme).toHaveAttribute("aria-selected", "true");
|
||||
await search.press("ArrowUp");
|
||||
await expect(editor).toHaveAttribute("aria-selected", "true");
|
||||
await expect(search).toBeFocused();
|
||||
});
|
||||
@@ -1,44 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("shortcut assignment fits the first stroke and conflict names in a narrow window", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 336, height: 540 });
|
||||
await page.keyboard.press("Meta+,");
|
||||
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
await settings.getByRole("treeitem", { name: "Keymap", exact: true }).click();
|
||||
await settings.getByRole("textbox", { name: "Search actions" }).fill("Find Action");
|
||||
const action = settings.getByRole("treeitem", { name: /Find Action/ });
|
||||
await action.click();
|
||||
await settings.getByRole("button", { name: "Add Keyboard Shortcut", exact: true }).click();
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Keyboard Shortcut: Find Action…", exact: true });
|
||||
const first = dialog.getByRole("textbox", { name: "First stroke" });
|
||||
const body = dialog.locator("[data-dialog-body]");
|
||||
const titleBar = dialog.locator("[data-dialog-titlebar]");
|
||||
await expect(first).toBeFocused();
|
||||
await expect(titleBar).toHaveText("Keyboard Shortcut");
|
||||
await expect(body.getByText("Find Action…", { exact: true })).toBeVisible();
|
||||
const firstBounds = (await first.boundingBox())!;
|
||||
const bodyBounds = (await body.boundingBox())!;
|
||||
expect(firstBounds.width).toBeGreaterThan(bodyBounds.width - 32);
|
||||
const conflicts = dialog.getByRole("list", { name: "Conflicts:" });
|
||||
await expect(conflicts).toHaveCount(0);
|
||||
|
||||
await first.press("Meta+Alt+L");
|
||||
await expect(conflicts).toBeVisible();
|
||||
await expect(conflicts.getByRole("listitem").filter({ hasText: "Reformat Code" }).first()).toBeVisible();
|
||||
expect(await conflicts.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
expect(
|
||||
await conflicts
|
||||
.getByRole("listitem")
|
||||
.evaluateAll((rows) => rows.every((row) => row.scrollHeight <= row.clientHeight)),
|
||||
).toBe(true);
|
||||
expect(await body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
|
||||
const ok = dialog.getByRole("button", { name: "OK", exact: true });
|
||||
await ok.click();
|
||||
const confirmation = page.getByRole("dialog", { name: "Warning", exact: true });
|
||||
await expect(confirmation.getByRole("list").getByText("Reformat Code", { exact: true })).toHaveCount(2);
|
||||
await confirmation.getByRole("button", { name: "Leave", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(action.locator("kbd").filter({ hasText: "⌥⌘L" })).toHaveCount(1);
|
||||
});
|
||||
@@ -102,9 +102,6 @@ test("edits the staged version and keeps an unsaved draft when the index changes
|
||||
await expect(headPane).toContainText("val committed = 0");
|
||||
await expect(indexPane).toContainText("val external = 3");
|
||||
await expect(localPane).not.toBeEmpty();
|
||||
const indexHeading = page.getByTitle(`Staged (index) ${path}`, { exact: true });
|
||||
await expect(indexHeading.getByText("build.gradle.kts", { exact: true })).toBeVisible();
|
||||
await expect(indexHeading.getByText("Staged (index)", { exact: true })).toBeVisible();
|
||||
const working = await localPane.textContent();
|
||||
|
||||
await page.getByRole("button", { name: "Unstage Change", exact: true }).click();
|
||||
|
||||
@@ -1,41 +1,5 @@
|
||||
import { expect, openFromTree, test } from "./fixtures";
|
||||
|
||||
test("the line separator menu has a heading and keeps the current choice visible", async ({ workbench: page }) => {
|
||||
await openFromTree(page, "build.gradle.kts");
|
||||
const status = page.locator('[data-status-item="editor.lineEnding"]').getByRole("button");
|
||||
const menu = page.getByRole("menu", { name: /^Line Separator$/i });
|
||||
const windows = "Windows (\\r\\n)";
|
||||
const unix = "Unix and macOS (\\n)";
|
||||
const classic = "Classic Mac OS (\\r)";
|
||||
await expect(status).toHaveText("LF");
|
||||
await status.click();
|
||||
const heading = menu.locator("..").getByText("Line Separator", { exact: true });
|
||||
expect(await heading.count()).toBe(1);
|
||||
await expect(heading).toHaveCSS("font-size", "13px");
|
||||
await expect(menu.locator('[role^="menuitem"]')).toHaveText([windows, unix, classic]);
|
||||
|
||||
await page.setViewportSize({ width: 540, height: 540 });
|
||||
await expect(heading).toBeInViewport({ ratio: 1 });
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: unix, checked: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(menu.getByRole("menuitem", { name: windows })).toBeFocused();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(status).toHaveText("CRLF");
|
||||
|
||||
await status.click();
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: windows, checked: true })).toBeFocused();
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(status).toHaveText("LF");
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const path = "/src/platform/i18n.ts";
|
||||
await (await import(/* @vite-ignore */ path)).setLocale("zh");
|
||||
});
|
||||
await status.click();
|
||||
const translated = page.getByRole("menu", { name: "行分隔符", exact: true });
|
||||
await expect(translated.getByRole("menuitem", { name: "Windows 换行 (\\r\\n)", exact: true })).toBeVisible();
|
||||
});
|
||||
|
||||
test("status bar uses its row height and widget insets in both densities", async ({ workbench: page }) => {
|
||||
const editor = await openFromTree(page, "build.gradle.kts");
|
||||
const bar = page.locator('footer[aria-label="Status bar"]');
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function openDialog(page: Page, id: "find.structural" | "find.replaceStructural") {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (id) => {
|
||||
window.__ipc.handlers.structural_languages = () => [
|
||||
{ id: "java", name: "Java" },
|
||||
{ id: "typescript", name: "TypeScript" },
|
||||
];
|
||||
window.__ipc.handlers.structural_validate = () => null;
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction(id);
|
||||
}, id);
|
||||
}
|
||||
|
||||
test("Structural Search puts language selection beside the taller template editor", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1080, height: 720 });
|
||||
await openDialog(page, "find.structural");
|
||||
const dialog = page.getByRole("dialog", { name: "Structural Search" });
|
||||
const editor = dialog.getByRole("textbox", { name: "Search template" });
|
||||
const label = dialog.locator("label").filter({ hasText: /^Search template$/ });
|
||||
const language = dialog.getByRole("button", { name: "Language", exact: true });
|
||||
await expect(editor).toBeFocused();
|
||||
await expect(language).toHaveText("Java");
|
||||
|
||||
const { x, y, width, height } = (await editor.boundingBox())!;
|
||||
const caption = (await label.boundingBox())!;
|
||||
const picker = (await language.boundingBox())!;
|
||||
expect(Math.abs(caption.y + caption.height / 2 - (picker.y + picker.height / 2))).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(caption.x - x)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(picker.x + picker.width - (x + width))).toBeLessThanOrEqual(1);
|
||||
expect(y - (picker.y + picker.height)).toBeLessThanOrEqual(6);
|
||||
expect(Math.abs(height - 150)).toBeLessThanOrEqual(1);
|
||||
|
||||
await language.click();
|
||||
await page.getByRole("option", { name: "TypeScript" }).click();
|
||||
await editor.fill("console.log($value$)");
|
||||
await expect
|
||||
.poll(() => ipcCalls(page, "structural_validate"))
|
||||
.toContainEqual({
|
||||
query: { language: "typescript", pattern: "console.log($value$)", replacement: null, maxMatches: 0 },
|
||||
});
|
||||
await expect(dialog.getByRole("button", { name: "Find", exact: true })).toBeEnabled();
|
||||
});
|
||||
|
||||
test("Structural Replace uses editor typography and fits the template controls in a narrow window", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 400, height: 620 });
|
||||
await openDialog(page, "find.replaceStructural");
|
||||
const dialog = page.getByRole("dialog", { name: "Structural Replace" });
|
||||
const search = dialog.getByRole("textbox", { name: "Search template" });
|
||||
const replacement = dialog.getByRole("textbox", { name: "Replace template" });
|
||||
await expect(search).toBeFocused();
|
||||
await page.evaluate(async () => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings, project } = useProject.getState();
|
||||
const current = settings ?? project?.settings;
|
||||
if (!current) throw new Error("Expected project settings");
|
||||
useProject.setState({
|
||||
settings: { ...current, editor: { ...current.editor, fontFamily: "Consolas", fontSize: 17, lineHeight: 26 } },
|
||||
});
|
||||
});
|
||||
|
||||
for (const template of [search, replacement]) {
|
||||
await expect(template).toHaveCSS("font-family", /^Consolas,/);
|
||||
await expect(template).toHaveCSS("font-size", "17px");
|
||||
await expect(template).toHaveCSS("line-height", "26px");
|
||||
const box = (await template.boundingBox())!;
|
||||
expect(box.x).toBeGreaterThanOrEqual(0);
|
||||
expect(box.x + box.width).toBeLessThanOrEqual(400);
|
||||
expect(Math.abs(box.height - 105)).toBeLessThanOrEqual(1);
|
||||
}
|
||||
await expect(dialog.getByRole("radio", { name: "Whole project" })).toBeInViewport();
|
||||
await replacement.fill("Objects.equals($a$, $b$)");
|
||||
await expect(replacement).toHaveValue("Objects.equals($a$, $b$)");
|
||||
await expect(dialog.getByRole("button", { name: "Cancel" })).toBeInViewport();
|
||||
});
|
||||
+4
-22
@@ -71,15 +71,7 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 },
|
||||
const search = terminal.getByRole("search", { name: "Find in terminal" });
|
||||
const input = search.getByRole("textbox", { name: "Find in terminal" });
|
||||
await input.fill("alpha");
|
||||
const count = search.locator("[aria-live=polite]");
|
||||
await expect(count).toHaveText(/\d+\/3/);
|
||||
await expect(count).toHaveCSS("font-size", "13px");
|
||||
const match = await count.textContent();
|
||||
// The incremental search can report after the first Enter; retry until Enter moves on.
|
||||
await expect(async () => {
|
||||
await input.press("Enter");
|
||||
await expect(count).not.toHaveText(match!, { timeout: 1000 });
|
||||
}).toPass();
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText(/\d+\/3/);
|
||||
if (process.env.OPENIDEA_TERMINAL_SHOTS)
|
||||
await terminal.screenshot({
|
||||
path: `${process.env.OPENIDEA_TERMINAL_SHOTS}/terminal-${width}${split ? "-split" : ""}.png`,
|
||||
@@ -91,19 +83,9 @@ for (const { width, split } of [{ width: 220 }, { width: 280 }, { width: 520 },
|
||||
expect(rect.x).toBeGreaterThanOrEqual(bounds.x);
|
||||
expect(rect.x + rect.width).toBeLessThanOrEqual(bounds.x + bounds.width + 1);
|
||||
}
|
||||
const matchCase = search.getByRole("button", { name: "Match Case", exact: true });
|
||||
const inputBox = (await input.boundingBox())!;
|
||||
if (width <= 280 || split) {
|
||||
expect(inputBox.width).toBeGreaterThan(bounds.width * 0.62);
|
||||
expect((await matchCase.boundingBox())!.y).toBeGreaterThan(inputBox.y + inputBox.height);
|
||||
} else {
|
||||
expect(inputBox.width).toBeGreaterThan(80);
|
||||
}
|
||||
const countBox = (await count.boundingBox())!;
|
||||
const previousBox = (await search.getByRole("button", { name: "Previous Occurrence", exact: true }).boundingBox())!;
|
||||
expect(previousBox.x - countBox.x - countBox.width).toBeLessThanOrEqual(4);
|
||||
expect(countBox.y + countBox.height / 2).toBeCloseTo(previousBox.y + previousBox.height / 2, 0);
|
||||
expect((await input.boundingBox())!.width).toBeGreaterThan(40);
|
||||
|
||||
const matchCase = search.getByRole("button", { name: "Match Case", exact: true });
|
||||
await matchCase.focus();
|
||||
await page.keyboard.press("Enter");
|
||||
await expect(matchCase).toHaveAttribute("aria-pressed", "true");
|
||||
@@ -148,7 +130,7 @@ test("wide terminal search leaves the grid in place and avoids covering the acti
|
||||
const top = (await search.boundingBox())!;
|
||||
expect(top.y).toBeCloseTo(before.y, 0);
|
||||
expect(top.x + top.width).toBeCloseTo(before.x + before.width, 0);
|
||||
expect(top.width).toBeLessThan(420);
|
||||
expect(top.width).toBeLessThan(before.width);
|
||||
|
||||
await input.fill("right-edge");
|
||||
await expect(search.locator("[aria-live=polite]")).toHaveText("1/1");
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function setEditorMetrics(page: Page, fontSize: number, lineHeight: number) {
|
||||
await page.evaluate(
|
||||
async ({ fontSize, lineHeight }) => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings, project } = useProject.getState();
|
||||
const current = settings ?? project?.settings;
|
||||
if (!current) throw new Error("Expected project settings");
|
||||
useProject.setState({ settings: { ...current, editor: { ...current.editor, fontSize, lineHeight } } });
|
||||
},
|
||||
{ fontSize, lineHeight },
|
||||
);
|
||||
}
|
||||
|
||||
async function openResults(page: Page) {
|
||||
await page.setViewportSize({ width: 1120, height: 720 });
|
||||
await stubDesktop(page);
|
||||
await setEditorMetrics(page, 20, 34);
|
||||
await page.evaluate(async () => {
|
||||
const lines = Array.from({ length: 1240 }, () => "");
|
||||
lines[1233] = " record(orderTotal);";
|
||||
lines[1237] = " return orderTotal;";
|
||||
window.__ipc.handlers.fs_read_text = () => lines.join("\n");
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
await executeAction("find.showUsageResults", {
|
||||
symbol: "orderTotal",
|
||||
locations: [
|
||||
{
|
||||
path: "/dev/acme-api/src/orderTotals.ts",
|
||||
range: { start: { line: 1233, col: 9 }, end: { line: 1233, col: 19 } },
|
||||
},
|
||||
{
|
||||
path: "/dev/acme-api/src/orderTotals.ts",
|
||||
range: { start: { line: 1237, col: 9 }, end: { line: 1237, col: 19 } },
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
const view = page.getByRole("region", { name: "Find Usages", exact: true });
|
||||
await view.getByRole("treeitem").filter({ hasText: "1234" }).click();
|
||||
const preview = view.getByRole("region", { name: "Preview", exact: true });
|
||||
await expect(preview.locator("mark")).toHaveCount(2);
|
||||
return { view, preview };
|
||||
}
|
||||
|
||||
test("Find Usages preview follows editor line height and fits long line numbers", async ({ workbench: page }) => {
|
||||
const { preview } = await openResults(page);
|
||||
await expect(preview).toHaveCSS("font-size", "20px");
|
||||
await expect(preview).toHaveCSS("line-height", "34px");
|
||||
|
||||
const number = preview.getByText("1234", { exact: true });
|
||||
const gutter = await number.evaluate((element) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
const text = range.getBoundingClientRect();
|
||||
const box = element.getBoundingClientRect();
|
||||
return { textInset: text.left - box.left, width: box.width };
|
||||
});
|
||||
expect(gutter.textInset).toBeGreaterThanOrEqual(1);
|
||||
await expect(number).toBeInViewport({ ratio: 0.98 });
|
||||
expect((await preview.getByText("999", { exact: true }).boundingBox())!.width).toBeCloseTo(gutter.width, 0);
|
||||
|
||||
await page.setViewportSize({ width: 560, height: 720 });
|
||||
await setEditorMetrics(page, 20, 39);
|
||||
await expect(preview).toHaveCSS("line-height", "39px");
|
||||
await expect(number).toBeInViewport({ ratio: 0.98 });
|
||||
});
|
||||
|
||||
test("Find Usages starts with equal panes and keeps a separate saved size for each orientation", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const { view } = await openResults(page);
|
||||
const divider = view.locator('[id="usages-preview-split"]').getByRole("separator");
|
||||
await expect(divider).toHaveAttribute("aria-valuenow", "50");
|
||||
await divider.press("ArrowRight");
|
||||
await expect(divider).not.toHaveAttribute("aria-valuenow", "50");
|
||||
const horizontal = (await divider.getAttribute("aria-valuenow"))!;
|
||||
|
||||
await page.setViewportSize({ width: 560, height: 720 });
|
||||
await expect(divider).toHaveAttribute("aria-orientation", "horizontal");
|
||||
await expect(divider).toHaveAttribute("aria-valuenow", "50");
|
||||
await divider.press("ArrowDown");
|
||||
await expect(divider).not.toHaveAttribute("aria-valuenow", "50");
|
||||
const vertical = (await divider.getAttribute("aria-valuenow"))!;
|
||||
|
||||
await page.setViewportSize({ width: 1120, height: 720 });
|
||||
await expect(divider).toHaveAttribute("aria-orientation", "vertical");
|
||||
await expect(divider).toHaveAttribute("aria-valuenow", horizontal);
|
||||
await page.setViewportSize({ width: 560, height: 720 });
|
||||
await expect(divider).toHaveAttribute("aria-valuenow", vertical);
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@@ -1,113 +0,0 @@
|
||||
# Self-Hosted GitHub Actions Runners
|
||||
|
||||
Runs _N_ persistent, isolated GitHub Actions runners via Docker Compose on a single Docker named volume (`runner-persist`) without requiring repository admin Personal Access Tokens.
|
||||
|
||||
In `.github/workflows/ci.yml`, the Linux leg of `Rust (${{ matrix.os }})` routes to `["self-hosted", "openidea-selfhosted"]` on trusted events (`push`, `merge_group`, `workflow_dispatch`, and same-repo pull requests) while the `SELFHOSTED_RUNNERS` repository variable is `true`. Fork pull requests, and every run while the variable is unset, use GitHub-hosted runners.
|
||||
|
||||
> **Availability requirement:** GitHub Actions `runs-on` cannot fall back to GitHub-hosted runners when no matching self-hosted runner is online; jobs stay queued until one connects. Set `SELFHOSTED_RUNNERS=true` (**Settings → Secrets and variables → Actions → Variables**) only once the runners are up, and delete it before taking the host down.
|
||||
|
||||
## Security Constraints
|
||||
|
||||
Because this repository is public and these runners retain persistent build caches and credentials across runs, workflows and runner hosts must follow these rules:
|
||||
|
||||
- **Trusted events only:** Route jobs to `openidea-selfhosted` only for `push`, `merge_group`, `workflow_dispatch`, or `pull_request` events where `github.event.pull_request.head.repo.full_name == github.repository`. Fork pull requests must stay on GitHub-hosted runners so untrusted code never reaches persistent caches or runner credentials.
|
||||
- **Read-only `GITHUB_TOKEN`:** Jobs targeting `openidea-selfhosted` must set `permissions: { contents: read }` (least privilege).
|
||||
- **No secret-bearing jobs:** Never pass repository or organization `secrets.*` to jobs running on `openidea-selfhosted`.
|
||||
- **Never feed releases:** Artifacts or outputs from `openidea-selfhosted` runners must never be uploaded for consumption by release or nightly workflows.
|
||||
- **Container isolation:** Jobs run as the `runner` user (`RUN_AS_ROOT=false`) from a pinned image tag and digest, but the image grants that user passwordless `sudo` (CI needs it for `apt-get`), so a job can become root inside its container. The container is the isolation boundary: never mount `/var/run/docker.sock` or host directories into it, and never run it `--privileged`.
|
||||
- **Shared build state:** Same-repo pull requests and `main` share each slot's Cargo target directory, so only collaborators you trust with `main`'s build should push branches to this repository.
|
||||
- **Network isolation:** Run the Docker host on an isolated network segment away from sensitive devices or internal services.
|
||||
|
||||
## How It Works
|
||||
|
||||
On startup, each container replica acquires an exclusive `flock` on a numeric slot (`1..N`) before dropping privileges to the `runner` user, isolating its persistent state under `/persist/slot-<N>/`:
|
||||
|
||||
| Path | Purpose |
|
||||
| --------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `runner-data/` | Saved `.runner` and `.credentials` reused across container restarts (`CONFIGURED_ACTIONS_RUNNER_FILES_DIR`) |
|
||||
| `work/` | Runner workspace and repository checkouts (`RUNNER_WORKDIR`) |
|
||||
| `cargo-target/` | Pre-compiled Rust build artifacts (`CARGO_TARGET_DIR`), kept outside checkouts so `actions/checkout` cleanup does not wipe it |
|
||||
| `cargo/` | Cargo crate registry and git cache (`CARGO_HOME`) |
|
||||
| `rustup/` | Installed Rust toolchains (`RUSTUP_HOME`) |
|
||||
| `pnpm-store/` | Content-addressable `pnpm` store on the same filesystem as `work/` for fast hardlinks into `node_modules` |
|
||||
| `toolcache/` | Tools cached by `actions/setup-*` (`/opt/hostedtoolcache`) |
|
||||
| `cache/` | General `/home/runner/.cache` directory |
|
||||
|
||||
All slots also share `/persist/shared/npm-cache` for downloaded npm tarballs.
|
||||
|
||||
## Prerequisites (First-Time Registration Only)
|
||||
|
||||
Ask a repository admin to generate **one** 1-hour registration token from:
|
||||
|
||||
> **GitHub Repository → Settings → Actions → Runners → New self-hosted runner**
|
||||
|
||||
A single registration token can register multiple runner slots within its 1-hour validity window. Once registered, each slot saves its own runner credentials and reconnects across restarts without needing a token again.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Run all commands from `scripts/selfhost-runner/`:
|
||||
|
||||
1. **Initial registration** (registers slots `1..4` and saves credentials):
|
||||
|
||||
```bash
|
||||
RUNNER_TOKEN=<one-time-token> docker compose up -d
|
||||
```
|
||||
|
||||
2. **Normal start, restart, or recreate** (no token needed once slots are registered):
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
docker compose restart
|
||||
```
|
||||
|
||||
3. **Scale down** (for example `4` → `2`):
|
||||
|
||||
```bash
|
||||
RUNNER_COUNT=2 docker compose up -d
|
||||
```
|
||||
|
||||
Docker Compose does not guarantee which container replicas it removes, so scaling `4` → `2` may leave slots `3` and `4` running rather than `1` and `2`. Stopped slots keep their saved credentials and caches on disk and will be reclaimed on the next restart or scale-up.
|
||||
|
||||
4. **Scale up** (for example `4` → `6`):
|
||||
|
||||
- If slots `5..6` were previously registered:
|
||||
|
||||
```bash
|
||||
RUNNER_COUNT=6 docker compose up -d
|
||||
```
|
||||
|
||||
- If slots `5..6` have never been registered:
|
||||
|
||||
```bash
|
||||
RUNNER_COUNT=6 RUNNER_TOKEN=<new-token> docker compose up -d
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
You can pass variables on the command line or place them in a local `.env` file in this directory (git-ignored):
|
||||
|
||||
| Variable | Default | Description |
|
||||
| -------------------- | ------------------------------------- | ---------------------------------------------------------------------- |
|
||||
| `RUNNER_COUNT` | `4` | Number of concurrent runner replicas |
|
||||
| `RUNNER_NAME_PREFIX` | `openidea-runner` | Runner name prefix; registers as `<prefix>-1`, `<prefix>-2`, … |
|
||||
| `RUNNER_LABELS` | `openidea-selfhosted` | Comma-separated labels attached to each runner |
|
||||
| `REPO_URL` | `https://github.com/l0ng-ai/openidea` | Target GitHub repository URL |
|
||||
| `RUNNER_TOKEN` | _(empty)_ | One-time registration token (required only when registering new slots) |
|
||||
|
||||
## Troubleshooting & Tips
|
||||
|
||||
- **Offline expiry (> 14 days) or deleted runner:** GitHub automatically removes runners that stay offline for more than 14 days. To clear a stale slot `<N>` and re-register it:
|
||||
|
||||
```bash
|
||||
docker compose run --rm --entrypoint /bin/bash github-runner \
|
||||
-c "rm -rf /persist/slot-<N>/runner-data/*"
|
||||
RUNNER_TOKEN=<new-token> docker compose up -d
|
||||
```
|
||||
|
||||
- **Full reset** (wipes all saved runner credentials and cached build artifacts):
|
||||
|
||||
```bash
|
||||
docker compose down -v
|
||||
```
|
||||
|
||||
- **Workflow caching tips:** `CARGO_TARGET_DIR` persists automatically across runs; CI enables incremental compilation on these runners and clears a slot's target directory once it exceeds 40 GB. To also preserve in-repo `node_modules/` across runs without re-linking, pass `clean: false` to `actions/checkout` (otherwise `pnpm install` quickly re-hardlinks packages from `pnpm-store/`).
|
||||
@@ -1,70 +0,0 @@
|
||||
# Self-hosted GitHub Actions runners (persistent & scalable).
|
||||
# See README.md in this directory for setup, security constraints, scaling, and troubleshooting.
|
||||
|
||||
services:
|
||||
github-runner:
|
||||
image: myoung34/github-runner:2.338.2-ubuntu-jammy@sha256:9944eb7fe15cff8f31ce6389a1cd39f5fb32627f56bdfa8a21fb27e56e99fa1a
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
replicas: ${RUNNER_COUNT:-4}
|
||||
|
||||
environment:
|
||||
RUNNER_SCOPE: repo
|
||||
REPO_URL: ${REPO_URL:-https://github.com/l0ng-ai/openidea}
|
||||
# Only needed the first time a new slot registers; registered slots reuse saved credentials.
|
||||
RUNNER_TOKEN: ${RUNNER_TOKEN:-}
|
||||
RUNNER_NAME_PREFIX: ${RUNNER_NAME_PREFIX:-openidea-runner}
|
||||
LABELS: ${RUNNER_LABELS:-openidea-selfhosted}
|
||||
DISABLE_AUTOMATIC_DEREGISTRATION: "true"
|
||||
RUN_AS_ROOT: "false"
|
||||
|
||||
# Claim an exclusive numeric slot (1..N) via flock so each replica gets its own
|
||||
# persistent runner credentials, workspace, Cargo target/home, rustup, pnpm store, and toolcache.
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- -ec
|
||||
- |
|
||||
mkdir -p /persist/slots /persist/shared/npm-cache /home/runner
|
||||
SLOT=1
|
||||
while true; do
|
||||
exec 99>"/persist/slots/slot-$${SLOT}.lock"
|
||||
if flock -n 99; then break; fi
|
||||
SLOT=$$((SLOT + 1))
|
||||
done
|
||||
SLOT_DIR="/persist/slot-$${SLOT}"
|
||||
mkdir -p "$${SLOT_DIR}"/{runner-data,work,cargo,cargo-target,rustup,pnpm-store,cache,toolcache}
|
||||
if [[ ! -f "$${SLOT_DIR}/runner-data/.runner" && -z "$${RUNNER_TOKEN:-}" ]]; then
|
||||
echo "ERROR: Slot $${SLOT} ($${RUNNER_NAME_PREFIX:-openidea-runner}-$${SLOT}) is not registered yet; set RUNNER_TOKEN to register it." >&2
|
||||
exit 1
|
||||
fi
|
||||
RUNNER_UID="$$(id -u runner)"
|
||||
RUNNER_GID="$$(id -g runner)"
|
||||
if [[ "$$(stat -c '%u' /persist/shared/npm-cache)" != "$${RUNNER_UID}" ]]; then
|
||||
chown -R "$${RUNNER_UID}:$${RUNNER_GID}" /persist/shared/npm-cache
|
||||
fi
|
||||
if [[ "$$(stat -c '%u' "$${SLOT_DIR}")" != "$${RUNNER_UID}" ]]; then
|
||||
chown -R "$${RUNNER_UID}:$${RUNNER_GID}" "$${SLOT_DIR}"
|
||||
fi
|
||||
chown "$${RUNNER_UID}:$${RUNNER_GID}" /persist/shared "$${SLOT_DIR}" "$${SLOT_DIR}"/{runner-data,work,cargo,cargo-target,rustup,pnpm-store,cache,toolcache}
|
||||
rm -rf /opt/hostedtoolcache /home/runner/.cache
|
||||
ln -s "$${SLOT_DIR}/toolcache" /opt/hostedtoolcache
|
||||
ln -s "$${SLOT_DIR}/cache" /home/runner/.cache
|
||||
chown -h "$${RUNNER_UID}:$${RUNNER_GID}" /opt/hostedtoolcache /home/runner/.cache
|
||||
export CONFIGURED_ACTIONS_RUNNER_FILES_DIR="$${SLOT_DIR}/runner-data"
|
||||
export RUNNER_NAME="$${RUNNER_NAME_PREFIX:-openidea-runner}-$${SLOT}"
|
||||
export RUNNER_WORKDIR="$${SLOT_DIR}/work"
|
||||
export CARGO_HOME="$${SLOT_DIR}/cargo"
|
||||
export RUSTUP_HOME="$${SLOT_DIR}/rustup"
|
||||
export CARGO_TARGET_DIR="$${SLOT_DIR}/cargo-target"
|
||||
export npm_config_store_dir="$${SLOT_DIR}/pnpm-store"
|
||||
export npm_config_cache="/persist/shared/npm-cache"
|
||||
export PATH="$${CARGO_HOME}/bin:$${PATH}"
|
||||
exec /entrypoint.sh "$$@"
|
||||
- --
|
||||
command: ["./bin/Runner.Listener", "run", "--startuptype", "service"]
|
||||
|
||||
volumes:
|
||||
- runner-persist:/persist
|
||||
|
||||
volumes:
|
||||
runner-persist:
|
||||
@@ -26,12 +26,12 @@ describe("the Language smoke workflow", () => {
|
||||
const { files, problems } = await smokeInputs(repo, workflow);
|
||||
expect(problems).toEqual([]);
|
||||
expect(describeUnselected(await unselected(workflow, [...files.keys()]), files)).toBe("");
|
||||
}, 20000);
|
||||
});
|
||||
|
||||
it("runs every language when a crate the smoke runs changes", async () => {
|
||||
const crates = rustSmokeInputs(repo);
|
||||
expect(describeUnselected(await unselected(workflow, [...crates.keys()]), crates)).toBe("");
|
||||
}, 20000);
|
||||
});
|
||||
});
|
||||
|
||||
const dirs: string[] = [];
|
||||
|
||||
@@ -143,6 +143,10 @@
|
||||
gap: var(--space-0-5);
|
||||
padding: 0 6px 0 8px;
|
||||
}
|
||||
.pin {
|
||||
color: var(--fg-muted);
|
||||
margin-left: -2px;
|
||||
}
|
||||
.deprecated {
|
||||
text-decoration-line: line-through;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import { useFileColors } from "@/workbench/fileColors";
|
||||
import { EmptyEditor } from "@/workbench/EditorArea";
|
||||
import {
|
||||
EmptyState,
|
||||
Icon,
|
||||
IconButton,
|
||||
Menu,
|
||||
SplitGroup,
|
||||
@@ -215,6 +216,7 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
? (gitRevisionOf(t.input.path)?.revision.slice(0, 8) ?? basename(dirname(t.input.path)))
|
||||
: null;
|
||||
const kindMark = tabTrailing(t.input, kinds);
|
||||
const pin = t.pinned ? <Icon name="pin" size={11} className={styles.pin} label="Pinned" /> : null;
|
||||
const file = t.input.kind === "file" && t.input.path ? files.get(t.input.path) : undefined;
|
||||
const title = markModified && dirty[i] ? `*${name}` : name;
|
||||
const prefix = t.input.kind === "file" && dupe ? (dupe.endsWith("/") ? dupe : `${dupe}/`) : null;
|
||||
@@ -240,7 +242,6 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
: tabIcon(t.input, kinds)
|
||||
: undefined,
|
||||
italic: t.preview,
|
||||
pinned: t.pinned,
|
||||
error: t.input.kind === "file" && errors[i],
|
||||
modified: dirty[i],
|
||||
// IDEA: hiding the close button is visual only. Keep close gestures
|
||||
@@ -251,7 +252,13 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
tints[i] || (fileColors && t.input.kind === "file" && t.input.path ? fileColors(t.input.path) : undefined),
|
||||
tintStrength: tints[i] ? undefined : "var(--file-tint-strength)",
|
||||
tooltip: virtualTooltip(t.input) ?? (showFullPathOnHover ? (t.input.path ?? name) : undefined),
|
||||
trailing: kindMark,
|
||||
trailing:
|
||||
kindMark || pin ? (
|
||||
<>
|
||||
{kindMark}
|
||||
{pin}
|
||||
</>
|
||||
) : undefined,
|
||||
};
|
||||
});
|
||||
}, [
|
||||
@@ -362,7 +369,6 @@ function PaneView({ paneId }: { paneId: string }) {
|
||||
onSelect={(id) => ctrl.activate(paneId, id)}
|
||||
onClose={(id) => void ctrl.closeTab(paneId, id)}
|
||||
onCloseOthers={(id) => void ctrl.closeOthers(paneId, id)}
|
||||
onTogglePin={(id) => ctrl.togglePin(paneId, id)}
|
||||
closeOnShiftClick
|
||||
onDoubleClick={(id) => {
|
||||
// IDEA: a preview tab becomes a regular one; any other tab maximizes the editor.
|
||||
|
||||
@@ -8,13 +8,12 @@
|
||||
* Exclude with Preserve Case, Esc closes. `FindPanel` is the bar itself, for
|
||||
* any CodeMirror view (the diff viewer's sides); `FindBar` is it on an editor pane.
|
||||
*/
|
||||
import { SearchHistoryMenu } from "@/ui/SearchHistoryMenu";
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { create } from "zustand";
|
||||
import clsx from "clsx";
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { Button, IconButton, Menu, SearchField, T, type MenuItem } from "@/ui";
|
||||
import { SEARCH_CONTEXTS, rememberSearch } from "@/platform/search";
|
||||
import { SEARCH_CONTEXTS, rememberSearch, searchHistory } from "@/platform/search";
|
||||
import { editorController, useFindBars, useTabs } from "../controller";
|
||||
import {
|
||||
countMatches,
|
||||
@@ -558,6 +557,19 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
|
||||
? "0 results"
|
||||
: `${count.current || "?"}/${count.total}${count.capped ? "+" : ""}`;
|
||||
|
||||
const historyItems = (kind: "find" | "replace"): MenuItem[] => {
|
||||
const h = searchHistory(kind);
|
||||
return h.length
|
||||
? [
|
||||
{ kind: "header", label: kind === "find" ? "Recent Searches" : "Recent Replacements" },
|
||||
...h.map((q) => ({
|
||||
label: q.replace(/\n/g, "⏎"),
|
||||
verbatim: true,
|
||||
run: () => setOpts(kind === "find" ? { search: q } : { replace: q }),
|
||||
})),
|
||||
]
|
||||
: [{ label: kind === "find" ? "No recent searches" : "No recent replacements", disabled: true }];
|
||||
};
|
||||
const filterItems: MenuItem[] = [
|
||||
{
|
||||
label: "Search In Selection",
|
||||
@@ -753,10 +765,12 @@ export function FindPanel({ target, version, replace, seq, onReplaceShown, onClo
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<SearchHistoryMenu
|
||||
kind={historyMenu}
|
||||
<Menu
|
||||
open={historyMenu !== null}
|
||||
anchor={historyMenu === "replace" ? replaceBoxRef : findBoxRef}
|
||||
onSelect={(value) => setOpts(historyMenu === "replace" ? { replace: value } : { search: value })}
|
||||
items={historyMenu ? historyItems(historyMenu) : []}
|
||||
placement="bottom-start"
|
||||
aria-label="Recent searches"
|
||||
onClose={() => setHistoryMenu(null)}
|
||||
/>
|
||||
<Menu
|
||||
|
||||
@@ -417,11 +417,6 @@ export function CaretStatus() {
|
||||
}
|
||||
|
||||
const EOL_LABEL: Record<LineEnding, string> = { lf: "LF", crLf: "CRLF", cr: "CR" };
|
||||
const EOL_CHOICES: { id: LineEnding; label: string }[] = [
|
||||
{ id: "crLf", label: "Windows (\\r\\n)" },
|
||||
{ id: "lf", label: "Unix and macOS (\\n)" },
|
||||
{ id: "cr", label: "Classic Mac OS (\\r)" },
|
||||
];
|
||||
|
||||
export function LineEndingStatus() {
|
||||
const meta = useActiveMeta();
|
||||
@@ -459,12 +454,12 @@ export function LineEndingStatus() {
|
||||
onClose={() => setOpen(false)}
|
||||
anchor={ref}
|
||||
placement="top-end"
|
||||
title="Line Separator"
|
||||
items={EOL_CHOICES.map(({ id, label }) => ({
|
||||
id,
|
||||
label,
|
||||
checked: meta.lineEnding === id ? true : undefined,
|
||||
run: () => choose(id),
|
||||
aria-label="Line separator"
|
||||
items={(["lf", "crLf", "cr"] as LineEnding[]).map((le) => ({
|
||||
id: le,
|
||||
label: `${EOL_LABEL[le]} – ${le === "lf" ? "Unix and macOS (\\n)" : le === "crLf" ? "Windows (\\r\\n)" : "Classic Mac OS (\\r)"}`,
|
||||
checked: meta.lineEnding === le ? true : undefined,
|
||||
run: () => choose(le),
|
||||
}))}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1045,7 +1045,6 @@ const completionPopup = ViewPlugin.fromClass(
|
||||
footer.className = "cm-lsp-completion-footer";
|
||||
const tip = document.createElement("span");
|
||||
tip.textContent = tx("Press ↵ to insert, ⇥ to replace");
|
||||
tip.title = tip.textContent;
|
||||
footer.append(tip, sortToggle(this.view));
|
||||
}
|
||||
// CodeMirror appends a fresh list when the candidates change.
|
||||
|
||||
+8
-21
@@ -212,28 +212,22 @@ export const lspTheme = EditorView.theme({
|
||||
color: "var(--fg-muted)",
|
||||
},
|
||||
".cm-lsp-completion-footer, .cm-lsp-inplace-footer": {
|
||||
display: "flex",
|
||||
flex: "none",
|
||||
flexWrap: "wrap",
|
||||
alignItems: "center",
|
||||
padding: "5px 12px",
|
||||
backgroundColor: "var(--bg-popup-inline, var(--bg-elev))",
|
||||
color: "var(--fg-subtle)",
|
||||
fontFamily: "var(--font-ui)",
|
||||
fontSize: "var(--fs-small)",
|
||||
gap: "var(--space-1) var(--space-3)",
|
||||
justifyContent: "space-between",
|
||||
borderRadius: "0 0 calc(var(--radius-popup) - 1px) calc(var(--radius-popup) - 1px)",
|
||||
},
|
||||
".cm-lsp-completion-footer": {
|
||||
display: "grid",
|
||||
gridTemplateColumns: "minmax(0, 1fr) minmax(0, max-content)",
|
||||
gap: "var(--space-2)",
|
||||
paddingBlock: "var(--space-1) 3px",
|
||||
paddingInline: "var(--space-3) var(--space-2)",
|
||||
},
|
||||
".cm-lsp-completion-footer > span, .cm-lsp-completion-sort": {
|
||||
minWidth: "0",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
},
|
||||
".cm-lsp-completion-sort": {
|
||||
flex: "none",
|
||||
maxWidth: "100%",
|
||||
padding: "0",
|
||||
border: "none",
|
||||
background: "none",
|
||||
@@ -496,14 +490,7 @@ export const lspTheme = EditorView.theme({
|
||||
'.cm-lsp-inplace-suggestions button[aria-current="true"]': {
|
||||
backgroundColor: "var(--bg-list-selected, var(--bg-tree-selected, var(--bg-selected-strong)))",
|
||||
},
|
||||
".cm-lsp-inplace-footer": {
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
padding: "5px 12px",
|
||||
gap: "var(--space-1) var(--space-3)",
|
||||
justifyContent: "space-between",
|
||||
overflowWrap: "anywhere",
|
||||
},
|
||||
".cm-lsp-inplace-footer": { overflowWrap: "anywhere" },
|
||||
|
||||
// --- floating lightbulb (intentions.ts) -----------------------------------
|
||||
".cm-lsp-bulb": {
|
||||
|
||||
@@ -161,51 +161,34 @@
|
||||
padding: 14px;
|
||||
}
|
||||
.scope {
|
||||
container: analysis-scope / inline-size;
|
||||
min-inline-size: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-0-5);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
padding: 4px 0 0 22px;
|
||||
}
|
||||
.grow {
|
||||
flex: 1;
|
||||
@@ -231,39 +214,21 @@
|
||||
flex: 1 1 12ch;
|
||||
min-width: 0;
|
||||
}
|
||||
.templateSection {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.templateHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.languageSelect {
|
||||
max-width: 50%;
|
||||
min-width: 180px;
|
||||
}
|
||||
.template {
|
||||
width: 100%;
|
||||
height: clamp(96px, 24vh, 150px);
|
||||
min-height: 50px;
|
||||
min-height: 96px;
|
||||
resize: vertical;
|
||||
padding: var(--space-1-5) var(--space-2);
|
||||
padding: 6px 8px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-editor);
|
||||
background: var(--bg-input);
|
||||
color: var(--fg-editor);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
line-height: var(--lh-code);
|
||||
}
|
||||
.replaceForm .template {
|
||||
/* Leave room for the scope and dialog controls when both templates are shown. */
|
||||
height: clamp(96px, calc(50vh - 205px), 150px);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.template:focus {
|
||||
outline: none;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** Inspect Code, Locate Duplicates and Search / Replace Structurally dialogs. */
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
call,
|
||||
commands,
|
||||
@@ -11,8 +10,6 @@ import {
|
||||
type WorkspaceEdit,
|
||||
} from "@/platform/ipc";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { editorPrefs } from "@/platform/editorSettings";
|
||||
import { monoFontFamily } from "@/platform/fonts";
|
||||
import { activeProfileId, listProfiles, validateInspections, type ProfileId } from "@/platform/inspections";
|
||||
import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { Button, Checkbox, Dialog, Input, Select, Spinner, T } from "@/ui";
|
||||
@@ -322,15 +319,6 @@ function StructuralDialog({ replace, onClose }: { replace: boolean; onClose: ()
|
||||
const [form, setForm] = useState<StructuralForm>(loadStructuralForm);
|
||||
const [scope, setScope] = useState<ScopeChoice>(() => defaultScope());
|
||||
const [busy, setBusy] = useState(false);
|
||||
const settings = useProject((s) => s.settings);
|
||||
const font = settings?.editor;
|
||||
const fallback = editorPrefs(settings).fallbackFont;
|
||||
const templateFont = {
|
||||
fontFamily:
|
||||
font?.fontFamily || fallback ? monoFontFamily(font?.fontFamily, fallback, "var(--font-mono)") : undefined,
|
||||
fontSize: font?.fontSize ?? undefined,
|
||||
lineHeight: font?.lineHeight != null ? `${font.lineHeight}px` : undefined,
|
||||
};
|
||||
const languages = useStructuralLanguages();
|
||||
// The editor's language when it has a grammar, else the first supported one.
|
||||
const language =
|
||||
@@ -369,49 +357,47 @@ function StructuralDialog({ replace, onClose }: { replace: boolean; onClose: ()
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={clsx(styles.form, replace && styles.replaceForm)}>
|
||||
<div className={styles.templateSection}>
|
||||
<div className={styles.templateHeader}>
|
||||
<label htmlFor="ssr-template">
|
||||
<T>Search template</T>
|
||||
</label>
|
||||
<Select
|
||||
value={language || null}
|
||||
options={options}
|
||||
onChange={(language) => setForm({ ...form, language })}
|
||||
placeholder={languages ? "No languages" : "Loading…"}
|
||||
className={styles.languageSelect}
|
||||
variant="ghost"
|
||||
aria-label="Language"
|
||||
/>
|
||||
</div>
|
||||
<textarea
|
||||
id="ssr-template"
|
||||
className={styles.template}
|
||||
style={templateFont}
|
||||
spellCheck={false}
|
||||
value={form.pattern}
|
||||
placeholder="$a$.equals($b$)"
|
||||
onChange={(e) => setForm({ ...form, pattern: e.target.value })}
|
||||
data-autofocus=""
|
||||
<div className={styles.form}>
|
||||
<div className={styles.fieldRow}>
|
||||
<span>
|
||||
<T>Language</T>
|
||||
</span>
|
||||
<Select
|
||||
value={language || null}
|
||||
options={options}
|
||||
onChange={(language) => setForm({ ...form, language })}
|
||||
placeholder={languages ? "No languages" : "Loading…"}
|
||||
className={styles.languageSelect}
|
||||
aria-label="Language"
|
||||
/>
|
||||
{error && <div className={styles.error}>{error}</div>}
|
||||
</div>
|
||||
<label className={styles.fieldLabel} htmlFor="ssr-template">
|
||||
<T>Search template</T>
|
||||
</label>
|
||||
<textarea
|
||||
id="ssr-template"
|
||||
className={styles.template}
|
||||
spellCheck={false}
|
||||
value={form.pattern}
|
||||
placeholder="$a$.equals($b$)"
|
||||
onChange={(e) => setForm({ ...form, pattern: e.target.value })}
|
||||
data-autofocus=""
|
||||
/>
|
||||
{error && <div className={styles.error}>{error}</div>}
|
||||
{replace && (
|
||||
<div className={styles.templateSection}>
|
||||
<label htmlFor="ssr-replacement">
|
||||
<>
|
||||
<label className={styles.fieldLabel} htmlFor="ssr-replacement">
|
||||
<T>Replace template</T>
|
||||
</label>
|
||||
<textarea
|
||||
id="ssr-replacement"
|
||||
className={styles.template}
|
||||
style={templateFont}
|
||||
spellCheck={false}
|
||||
value={form.replacement}
|
||||
placeholder="Objects.equals($a$, $b$)"
|
||||
onChange={(e) => setForm({ ...form, replacement: e.target.value })}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className={styles.hint}>
|
||||
<T>Placeholders:</T> <code>$name$</code> or <code>$NAME</code> <T>match one node,</T> <code>$$$NAME</code>{" "}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/** 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, Radio, Select, T } from "@/ui";
|
||||
import { Button, IconButton, Input, Select, T } from "@/ui";
|
||||
import { SCOPE_LABELS, currentFile, type ScopeChoice, type ScopeKind } from "./scope";
|
||||
import styles from "./Analysis.module.css";
|
||||
|
||||
@@ -63,69 +62,57 @@ 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>
|
||||
<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>
|
||||
{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>
|
||||
)}
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
mavenRoots,
|
||||
nodeIcon,
|
||||
nodeLabel,
|
||||
pluginCoordinates,
|
||||
profileChecked,
|
||||
withGradleOptions,
|
||||
gradleHasTestTask,
|
||||
@@ -311,8 +310,6 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const plugin = node.kind === "plugin" ? node.plugin : null;
|
||||
const coordinates = plugin && `(${pluginCoordinates(plugin)})`;
|
||||
const detail =
|
||||
node.kind === "profiles" && node.projectRoot
|
||||
? node.projectRoot.split("/").pop()
|
||||
@@ -320,28 +317,18 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
? `(${node.dependency.scope}${node.dependency.optional ? ", optional" : ""})`
|
||||
: node.kind === "dependency" && node.dependency.optional
|
||||
? "(optional)"
|
||||
: null;
|
||||
: node.kind === "task"
|
||||
? node.task.description
|
||||
: null;
|
||||
const skipped =
|
||||
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
|
||||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
|
||||
const label = (
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{plugin?.prefix ?? nodeLabel(node)}
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<span className={styles.row}>
|
||||
<span className={styles.row} title={node.kind === "task" ? (node.task.description ?? undefined) : undefined}>
|
||||
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
|
||||
{coordinates ? (
|
||||
<span className={styles.pluginText}>
|
||||
{label}
|
||||
<span className={styles.detail} title={coordinates}>
|
||||
{coordinates}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{nodeLabel(node)}
|
||||
</span>
|
||||
{detail && <span className={styles.detail}>{detail}</span>}
|
||||
</span>
|
||||
);
|
||||
@@ -488,7 +475,6 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
|
||||
roots={roots}
|
||||
getKey={(n) => n.key}
|
||||
getLabel={nodeLabel}
|
||||
getTooltip={(n) => (n.kind === "task" ? (n.task.description ?? undefined) : undefined)}
|
||||
getChildren={getChildren}
|
||||
isExpandable={(n) => !!getChildren(n)?.length}
|
||||
expanded={expanded}
|
||||
|
||||
@@ -96,18 +96,6 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.pluginText {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.pluginText > .label {
|
||||
flex: none;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.profile {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
|
||||
return parts.join(":");
|
||||
}
|
||||
|
||||
export function pluginCoordinates(p: MavenPlugin): string {
|
||||
return `${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""}`;
|
||||
export function pluginLabel(p: MavenPlugin): string {
|
||||
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
|
||||
}
|
||||
|
||||
/** Profile choices in different workspace members are independent. */
|
||||
@@ -363,7 +363,7 @@ export function nodeLabel(node: BuildNode): string {
|
||||
case "plugins":
|
||||
return tx("Plugins");
|
||||
case "plugin":
|
||||
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
|
||||
return pluginLabel(node.plugin);
|
||||
case "goal":
|
||||
return `${node.plugin.prefix}:${node.goal}`;
|
||||
case "dependencies":
|
||||
|
||||
@@ -30,16 +30,6 @@
|
||||
.strong {
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
.strong,
|
||||
.rootDetail,
|
||||
.directory {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.row > svg {
|
||||
flex: none;
|
||||
}
|
||||
.selected {
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
@@ -47,26 +37,6 @@
|
||||
flex: none;
|
||||
color: var(--fg-subtle);
|
||||
}
|
||||
.rootDetail {
|
||||
max-width: 50%;
|
||||
}
|
||||
.fileLabel {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
.fileName {
|
||||
flex: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
.muted.directory {
|
||||
flex: 0 1 auto;
|
||||
}
|
||||
.duration {
|
||||
margin-inline-start: auto;
|
||||
font-size: var(--fs-small);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.fileIcon {
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
|
||||
@@ -67,12 +67,13 @@ function StatusIcon({ status }: { status: BuildStatus }) {
|
||||
return <Icon name={name} size={14} className={styles[`status-${status}`]} />;
|
||||
}
|
||||
|
||||
function rootDetail(status: BuildStatus, errors: number, warnings: number): string {
|
||||
function rootDetail(status: BuildStatus, durationMs: number | null, errors: number, warnings: number): string {
|
||||
if (status === "running") return "running…";
|
||||
if (status === "cancelled") return "cancelled";
|
||||
if (status === "success") return tx("Finished");
|
||||
const summary = finishSummary({ success: false, errors, warnings, durationMs: null });
|
||||
return summary.replace(/^Build failed:?\s*/, "") || "failed";
|
||||
const summary = finishSummary({ success: status === "success", errors, warnings, durationMs });
|
||||
return status === "success"
|
||||
? `finished ${formatDuration(durationMs ?? 0)}`
|
||||
: summary.replace(/^Build failed:?\s*/, "") || "failed";
|
||||
}
|
||||
|
||||
export function BuildHeaderActions() {
|
||||
@@ -129,19 +130,15 @@ function BuildTree() {
|
||||
|
||||
const renderNode = (n: BuildNode, state: TreeRowState) => {
|
||||
if (n.kind === "root") {
|
||||
const detail = rootDetail(n.status, n.errors, n.warnings);
|
||||
const elapsed = n.status !== "running" && durationMs != null ? formatDuration(durationMs) : null;
|
||||
return (
|
||||
<span className={styles.row} title={[n.title, detail, elapsed].filter(Boolean).join(" ")}>
|
||||
<span className={styles.row}>
|
||||
<StatusIcon status={n.status} />
|
||||
<span className={styles.strong}>{n.title}</span>
|
||||
<span className={clsx(styles.muted, styles.rootDetail)}>{detail}</span>
|
||||
{elapsed && <span className={clsx(styles.muted, styles.duration)}>{elapsed}</span>}
|
||||
<span className={styles.muted}>{rootDetail(n.status, durationMs, n.errors, n.warnings)}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (n.kind === "file") {
|
||||
const directory = relativeDir(root, n.path);
|
||||
const errors = n.messages.filter((m) => m.severity === "error").length;
|
||||
const warnings = n.messages.filter((m) => m.severity === "warning").length;
|
||||
const counts = [
|
||||
@@ -151,22 +148,13 @@ function BuildTree() {
|
||||
.filter(Boolean)
|
||||
.join(", ");
|
||||
return (
|
||||
<span className={styles.row} title={n.path}>
|
||||
<span className={styles.row}>
|
||||
<Icon name={fileIconName(basename(n.path), n.path)} size={16} className={styles.fileIcon} />
|
||||
<span className={styles.fileLabel}>
|
||||
<span
|
||||
className={clsx(
|
||||
styles.strong,
|
||||
styles.fileName,
|
||||
errors > 0 && styles.fileError,
|
||||
state.selected && styles.selected,
|
||||
)}
|
||||
>
|
||||
{basename(n.path)}
|
||||
</span>
|
||||
{directory && <span className={clsx(styles.muted, styles.directory)}>{directory}</span>}
|
||||
<span className={clsx(styles.strong, errors > 0 && styles.fileError, state.selected && styles.selected)}>
|
||||
{basename(n.path)}
|
||||
</span>
|
||||
{counts && <span className={styles.muted}>{counts}</span>}
|
||||
<span className={styles.muted}>{relativeDir(root, n.path)}</span>
|
||||
<span className={styles.muted}>{counts}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
flex: none;
|
||||
}
|
||||
.vertical {
|
||||
flex-direction: column;
|
||||
padding: 3px 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
import { create } from "zustand";
|
||||
import clsx from "clsx";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { IconButton } from "@/ui";
|
||||
import type { Usage } from "./usages";
|
||||
import styles from "./UsageAccessFilter.module.css";
|
||||
@@ -47,16 +45,11 @@ export function filterUsageAccess(items: readonly Usage[], options: UsageAccessO
|
||||
|
||||
export const supportsUsageAccess = (items: readonly Usage[]) => items.some((u) => u.access && u.access !== "unknown");
|
||||
|
||||
export function UsageAccessFilter({ items, vertical }: { items: readonly Usage[]; vertical?: boolean }) {
|
||||
const tx = useTx();
|
||||
export function UsageAccessFilter({ items }: { items: readonly Usage[] }) {
|
||||
const options = useUsageAccessOptions();
|
||||
if (!supportsUsageAccess(items)) return null;
|
||||
return (
|
||||
<div
|
||||
className={clsx(styles.toolbar, vertical && styles.vertical)}
|
||||
role={vertical ? "group" : "toolbar"}
|
||||
aria-label={tx("Usage access filters")}
|
||||
>
|
||||
<div className={styles.toolbar} role="toolbar" aria-label="Usage access filters">
|
||||
<IconButton
|
||||
icon="show-read-access"
|
||||
size="small"
|
||||
|
||||
@@ -176,7 +176,6 @@ function UsagesPopupInner() {
|
||||
</span>
|
||||
</span>
|
||||
<div className={styles.actions}>
|
||||
<UsageAccessFilter items={all} />
|
||||
{scope && (
|
||||
<Select<UsageScope>
|
||||
variant="ghost"
|
||||
@@ -214,6 +213,7 @@ function UsagesPopupInner() {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<UsageAccessFilter items={all} />
|
||||
{note && (
|
||||
<div className={styles.note} data-testid="usages-note">
|
||||
{note}
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
gap: var(--space-0-5);
|
||||
padding: 4px 0;
|
||||
border-right: 1px solid var(--border);
|
||||
overflow-y: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.toolbarSep {
|
||||
flex: none;
|
||||
width: 16px;
|
||||
height: 1px;
|
||||
margin: 3px 0;
|
||||
@@ -69,6 +66,7 @@
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
.body > [role="toolbar"],
|
||||
.body > .summary {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
@@ -159,7 +157,7 @@
|
||||
flex-direction: column;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
line-height: var(--lh-code);
|
||||
line-height: 1.45;
|
||||
}
|
||||
.sourcePreview .sourceText[role="region"] {
|
||||
font: inherit;
|
||||
|
||||
@@ -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>
|
||||
@@ -406,8 +406,6 @@ export function useUsagesHeaderMenu(): MenuItem[] {
|
||||
];
|
||||
}
|
||||
|
||||
const DEFAULT_PREVIEW_LAYOUT = { usages: 50, preview: 50 };
|
||||
|
||||
function UsagesSplit({ preview, children }: { preview: ReactNode; children: ReactNode }) {
|
||||
const show = useUsagesOptions((s) => s.preview);
|
||||
const frame = useRef<HTMLDivElement>(null);
|
||||
@@ -429,13 +427,12 @@ function UsagesSplit({ preview, children }: { preview: ReactNode; children: Reac
|
||||
orientation={stacked ? "vertical" : "horizontal"}
|
||||
id="usages-preview-split"
|
||||
storageKey={stacked ? "openidea.usages.previewSplit.vertical" : "openidea.usages.previewSplit"}
|
||||
defaultLayout={DEFAULT_PREVIEW_LAYOUT}
|
||||
>
|
||||
<SplitPanel id="usages" minSize={stacked ? "30%" : 160} className={styles.panel}>
|
||||
{children}
|
||||
</SplitPanel>
|
||||
<SplitHandle />
|
||||
<SplitPanel id="preview" minSize={stacked ? "30%" : 160} className={styles.panel}>
|
||||
<SplitPanel id="preview" minSize={stacked ? "30%" : 160} defaultSize="45%" className={styles.panel}>
|
||||
{preview}
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
@@ -458,21 +455,13 @@ function UsagesPreview({ node }: { node: Node | null }) {
|
||||
return (group?.usages ?? []).map((u) => ({ line: u.line, ranges: [[u.col, u.endCol] as const] }));
|
||||
}, [usage, search?.groups]);
|
||||
return (
|
||||
<div
|
||||
className={styles.sourcePreview}
|
||||
style={{
|
||||
fontFamily,
|
||||
fontSize: settings?.fontSize ?? undefined,
|
||||
lineHeight: settings?.lineHeight != null ? `${settings.lineHeight}px` : undefined,
|
||||
}}
|
||||
>
|
||||
<div className={styles.sourcePreview} style={{ fontFamily, fontSize: settings?.fontSize ?? undefined }}>
|
||||
<SourcePreview
|
||||
path={usage?.path ?? null}
|
||||
line={usage?.line ?? 0}
|
||||
highlights={highlights}
|
||||
load={previewText}
|
||||
colorize={previewColors}
|
||||
editorLayout
|
||||
className={styles.sourceText}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@ it("shows a plain count for unclassified searches after a Java access mode was s
|
||||
});
|
||||
const view = render(<UsagesView />);
|
||||
expect(screen.getByText("2 results")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("group", { name: "Usage access filters" })).toBeNull();
|
||||
expect(screen.queryByRole("toolbar", { name: "Usage access filters" })).toBeNull();
|
||||
view.unmount();
|
||||
useUsageAccessOptions.setState({ read: true, write: true });
|
||||
useUsages.setState({ tabs: [], active: null });
|
||||
|
||||
@@ -241,8 +241,7 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
|
||||
const filter = screen.getByRole("textbox", { name: "筛选类" });
|
||||
expect(filter.getAttribute("placeholder")).toBe("筛选类");
|
||||
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
|
||||
} finally {
|
||||
await setLocale("en");
|
||||
}
|
||||
@@ -300,15 +299,10 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByText("Cache$Entry")).toBeTruthy();
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
|
||||
const options = screen.getByRole("button", { name: "View Options" });
|
||||
fireEvent.click(options);
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
|
||||
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
|
||||
expect(screen.getByText("Heap$Live")).toBeTruthy();
|
||||
expect(screen.queryByText("Cache$Entry")).toBeNull();
|
||||
expect(screen.queryByText("Dup")).toBeNull();
|
||||
expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
fireEvent.click(options);
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: true })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("sorts by the clicked column and reports it with aria-sort", async () => {
|
||||
|
||||
@@ -38,7 +38,7 @@ afterEach(() => {
|
||||
|
||||
describe("value hint", () => {
|
||||
it("keeps a hint whose value was expanded past the hint's timeout", () => {
|
||||
showHint(view, () => valueHint(view, "order", order, session), { pos: 0, timeout: 4000 });
|
||||
showHint(view, () => valueHint("order", order, session), { pos: 0, timeout: 4000 });
|
||||
expand();
|
||||
expect(document.querySelector(".cm-lsp-hint .tree")).not.toBeNull();
|
||||
vi.advanceTimersByTime(60_000);
|
||||
@@ -47,7 +47,7 @@ describe("value hint", () => {
|
||||
|
||||
it("hands an expanded hover hint to its pin instead of growing in place", () => {
|
||||
const pin = vi.fn();
|
||||
showHint(view, () => valueHint(view, "order", order, session, 400, { pin }), { pos: 0 });
|
||||
showHint(view, () => valueHint("order", order, session, 400, { pin }), { pos: 0 });
|
||||
expand();
|
||||
expect(pin).toHaveBeenCalled();
|
||||
expect(document.querySelector(".tree")).toBeNull();
|
||||
|
||||
@@ -169,25 +169,13 @@
|
||||
|
||||
/* Data Views › Show value tooltip on mouse hover. */
|
||||
.valueTooltip {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-1);
|
||||
max-width: min(90vw, calc(var(--debug-value-editor-width, 100vw) - var(--space-2)));
|
||||
padding: var(--space-1) var(--space-2);
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--fs-ui);
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.valueText {
|
||||
min-width: 0;
|
||||
max-width: 520px;
|
||||
padding: 4px 8px;
|
||||
font-family: var(--font-mono);
|
||||
font-weight: var(--fw-code);
|
||||
font-size: var(--fs-code);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.valueGlyph {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
margin-top: 1px;
|
||||
word-break: break-word;
|
||||
}
|
||||
.valueTooltipTree {
|
||||
display: flex;
|
||||
@@ -206,22 +194,19 @@
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
:global(.cm-lsp-hint):has(> .valueTooltip) {
|
||||
padding: 0;
|
||||
}
|
||||
.valueExpand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
margin-top: 1px;
|
||||
margin-right: 4px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: var(--radius-small);
|
||||
background: transparent;
|
||||
color: var(--fg-muted);
|
||||
vertical-align: -3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.valueExpand:hover {
|
||||
|
||||
@@ -49,7 +49,7 @@ class InlineValues extends WidgetType {
|
||||
e.stopPropagation();
|
||||
const session = activeSession();
|
||||
if (!session || session.status !== "paused") return;
|
||||
showHint(view, () => valueHint(view, part.name, part.variable, session.id, null), {
|
||||
showHint(view, () => valueHint(part.name, part.variable, session.id, null), {
|
||||
pos: view.posAtDOM(piece),
|
||||
timeout: 60_000,
|
||||
});
|
||||
@@ -65,7 +65,7 @@ class InlineValues extends WidgetType {
|
||||
e.stopPropagation();
|
||||
const session = activeSession();
|
||||
if (!session || session.status !== "paused") return;
|
||||
showHint(view, () => valueHint(view, part.name, part.variable, session.id, null), {
|
||||
showHint(view, () => valueHint(part.name, part.variable, session.id, null), {
|
||||
pos: view.posAtDOM(show),
|
||||
timeout: 60_000,
|
||||
});
|
||||
|
||||
@@ -13,7 +13,6 @@ import { activeSession, evaluate, useDebug } from "../state";
|
||||
import { inlineValue, shownValue } from "../values";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { iconMarkup, selectableText } from "@/ui";
|
||||
import { iconNode } from "@/ui/iconNode";
|
||||
import { mountValueTree } from "../ui/ValueHintTree";
|
||||
import styles from "./editor.module.css";
|
||||
|
||||
@@ -97,7 +96,6 @@ export function expressionAt(
|
||||
|
||||
/** IDEA's value hint: `expression = value {type}`, objects expandable into a variables tree in place. */
|
||||
export function valueHint(
|
||||
view: EditorView,
|
||||
expression: string,
|
||||
value: Variable,
|
||||
session: DebugSessionId,
|
||||
@@ -106,21 +104,15 @@ export function valueHint(
|
||||
): { dom: HTMLElement; destroy: () => void } {
|
||||
const dom = document.createElement("div");
|
||||
dom.className = `${styles.valueTooltip} ${selectableText}`;
|
||||
const stopSizing = watchHintWidth(view, dom);
|
||||
let tree: { unmount(): void } | null = null;
|
||||
const destroy = () => {
|
||||
stopSizing();
|
||||
tree?.unmount();
|
||||
};
|
||||
const expandTree = () => {
|
||||
dom.classList.remove(styles.valueTooltip!);
|
||||
dom.classList.replace(selectableText, styles.valueTooltipTree!);
|
||||
dom.replaceChildren();
|
||||
tree = mountValueTree(dom, expression, value, session);
|
||||
};
|
||||
if (value.variablesReference > 0 && opts.expanded) {
|
||||
expandTree();
|
||||
return { dom, destroy };
|
||||
return { dom, destroy: () => tree?.unmount() };
|
||||
}
|
||||
if (value.variablesReference > 0) {
|
||||
// IDEA's value hint: the "+" expands the object into a variables tree in place.
|
||||
@@ -139,8 +131,6 @@ export function valueHint(
|
||||
});
|
||||
dom.append(expand);
|
||||
}
|
||||
const summary = document.createElement("span");
|
||||
summary.className = styles.valueText!;
|
||||
const name = document.createElement("span");
|
||||
name.className = styles.valueName!;
|
||||
name.textContent = `${expression} = `;
|
||||
@@ -153,33 +143,11 @@ export function valueHint(
|
||||
span.textContent = text;
|
||||
return span;
|
||||
};
|
||||
summary.append(name);
|
||||
if (leading) summary.append(type(`${shown.label} `));
|
||||
summary.append(max === null ? shown.text : inlineValue(shown.text, max));
|
||||
if (shown.label && !leading) summary.append(type(` ${shown.label}`));
|
||||
dom.append(iconNode("variable", 16, styles.valueGlyph), summary);
|
||||
return { dom, destroy };
|
||||
}
|
||||
|
||||
function watchHintWidth(view: EditorView, dom: HTMLElement): () => void {
|
||||
let width = 0;
|
||||
let resizeFrame = 0;
|
||||
const updateWidth = () => {
|
||||
const next = view.dom.clientWidth;
|
||||
if (!next || next === width) return;
|
||||
width = next;
|
||||
dom.style.setProperty("--debug-value-editor-width", `${width}px`);
|
||||
};
|
||||
updateWidth();
|
||||
const resize = new ResizeObserver(() => {
|
||||
cancelAnimationFrame(resizeFrame);
|
||||
resizeFrame = requestAnimationFrame(updateWidth);
|
||||
});
|
||||
resize.observe(view.dom);
|
||||
return () => {
|
||||
resize.disconnect();
|
||||
cancelAnimationFrame(resizeFrame);
|
||||
};
|
||||
dom.append(name);
|
||||
if (leading) dom.append(type(`${shown.label} `));
|
||||
dom.append(max === null ? shown.text : inlineValue(shown.text, max));
|
||||
if (shown.label && !leading) dom.append(type(` ${shown.label}`));
|
||||
return { dom, destroy: () => tree?.unmount() };
|
||||
}
|
||||
|
||||
export function showQuickValue(
|
||||
@@ -190,7 +158,7 @@ export function showQuickValue(
|
||||
session: DebugSessionId,
|
||||
) {
|
||||
if (value.variablesReference > 0) showValueTree(view, pos, expression, value, session);
|
||||
else showHint(view, () => valueHint(view, expression, value, session), { pos, timeout: 60_000 });
|
||||
else showHint(view, () => valueHint(expression, value, session), { pos, timeout: 60_000 });
|
||||
}
|
||||
|
||||
export function valueTooltip(): Extension {
|
||||
@@ -217,7 +185,7 @@ export function valueTooltip(): Extension {
|
||||
end: expr.to,
|
||||
above: true,
|
||||
create: (view) =>
|
||||
valueHint(view, expr.text, value, session.id, 400, {
|
||||
valueHint(expr.text, value, session.id, 400, {
|
||||
// The tree outgrows the hint and may move to the other side of the line, away from the
|
||||
// mouse, which closed the hover tooltip before it could be reached. Like IDEA's value
|
||||
// popup it stays until Escape, a click in the editor or the next step.
|
||||
@@ -240,7 +208,21 @@ function pinnedTree(view: EditorView, expression: string, value: Variable, sessi
|
||||
const unsubscribe = useDebug.subscribe((s) => {
|
||||
if (s.stopSeq !== stop || s.sessions[session]?.status !== "paused") hideHint(view);
|
||||
});
|
||||
const hint = valueHint(view, expression, value, session, 400, { expanded: true });
|
||||
const hint = valueHint(expression, value, session, 400, { expanded: true });
|
||||
let width = 0;
|
||||
let resizeFrame = 0;
|
||||
const updateWidth = () => {
|
||||
const next = view.dom.clientWidth;
|
||||
if (!next || next === width) return;
|
||||
width = next;
|
||||
hint.dom.style.setProperty("--debug-value-editor-width", `${width}px`);
|
||||
};
|
||||
updateWidth();
|
||||
const resize = new ResizeObserver(() => {
|
||||
cancelAnimationFrame(resizeFrame);
|
||||
resizeFrame = requestAnimationFrame(updateWidth);
|
||||
});
|
||||
resize.observe(view.dom);
|
||||
// The tree has the focus, so the editor's Escape doesn't reach the hint.
|
||||
hint.dom.addEventListener("keydown", (e) => {
|
||||
if (e.key !== "Escape" || e.defaultPrevented) return;
|
||||
@@ -251,6 +233,8 @@ function pinnedTree(view: EditorView, expression: string, value: Variable, sessi
|
||||
return {
|
||||
dom: hint.dom,
|
||||
destroy: () => {
|
||||
resize.disconnect();
|
||||
cancelAnimationFrame(resizeFrame);
|
||||
unsubscribe();
|
||||
hint.destroy();
|
||||
},
|
||||
@@ -303,10 +287,7 @@ export function selectionValueTooltip(): Extension {
|
||||
}
|
||||
// The selection moved on while evaluating.
|
||||
if (seq !== this.seq) return;
|
||||
showHint(this.view, () => valueHint(this.view, expr.text, value, session.id), {
|
||||
pos: expr.from,
|
||||
timeout: 60_000,
|
||||
});
|
||||
showHint(this.view, () => valueHint(expr.text, value, session.id), { pos: expr.from, timeout: 60_000 });
|
||||
}
|
||||
|
||||
destroy() {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
}
|
||||
|
||||
.filter {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
flex: 0 1 240px;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.banner,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Memory tab of the Debug tool window: live instance counts per class of the debugged JVM, and heap capture. */
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import clsx from "clsx";
|
||||
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
|
||||
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
|
||||
@@ -112,8 +112,6 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
const id = session.id;
|
||||
const entry = useMemory((s) => s.bySession[id]);
|
||||
const query = entry?.query ?? DEFAULT_QUERY;
|
||||
const optionsButton = useRef<HTMLButtonElement>(null);
|
||||
const [optionsOpen, setOptionsOpen] = useState(false);
|
||||
const result = entry?.result ?? null;
|
||||
const snapshot = entry?.snapshot ?? null;
|
||||
const source = snapshot?.source ?? "histogram";
|
||||
@@ -163,37 +161,17 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
disabled={entry?.loading || !canRefresh}
|
||||
/>
|
||||
<HeapCaptureButton session={session} />
|
||||
<SearchField
|
||||
<Input
|
||||
className={styles.filter}
|
||||
value={query.filter}
|
||||
onChange={(filter) => setMemoryQuery(id, { filter })}
|
||||
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
|
||||
placeholder="Filter classes"
|
||||
aria-label="Filter classes"
|
||||
/>
|
||||
<IconButton
|
||||
ref={optionsButton}
|
||||
icon="settings"
|
||||
title="View Options"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
pressed={query.changedOnly}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={optionsOpen}
|
||||
onClick={() => setOptionsOpen(!optionsOpen)}
|
||||
/>
|
||||
<Menu
|
||||
open={optionsOpen}
|
||||
onClose={() => setOptionsOpen(false)}
|
||||
anchor={optionsButton}
|
||||
placement="bottom-end"
|
||||
aria-label="View Options"
|
||||
items={[
|
||||
{
|
||||
label: "Changed only",
|
||||
checked: query.changedOnly,
|
||||
run: () => setMemoryQuery(id, { changedOnly: !query.changedOnly }),
|
||||
},
|
||||
]}
|
||||
<Checkbox
|
||||
checked={query.changedOnly}
|
||||
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
|
||||
label="Changed only"
|
||||
/>
|
||||
</div>
|
||||
{backend && (
|
||||
|
||||
@@ -12,6 +12,11 @@ export function isTableType(typeName: string | null | undefined): boolean {
|
||||
return !!typeName && TABLE_TYPES.has(typeName);
|
||||
}
|
||||
|
||||
/** Numbers are right-aligned, as in the database grid. */
|
||||
export function isNumericDtype(dtype: string | undefined): boolean {
|
||||
return !!dtype && /^(u?int|float|complex|Int|UInt|Float)\d*$/.test(dtype);
|
||||
}
|
||||
|
||||
export const ROW_PAGE = 100;
|
||||
export const COLUMN_PAGE = 30;
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding: 16px;
|
||||
color: var(--fg-faint);
|
||||
@@ -17,53 +21,12 @@
|
||||
}
|
||||
|
||||
/* breakpoint popover */
|
||||
.bpPopover {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 400px;
|
||||
overflow: hidden;
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.bpPopoverTitle,
|
||||
.bpFooter {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-2) var(--space-3);
|
||||
}
|
||||
|
||||
.bpPopoverTitle {
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bpPopoverTitle > svg {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.bpPopoverTitle .bpFile {
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.bpPopoverFields {
|
||||
.bpEditor {
|
||||
width: 340px;
|
||||
padding: 10px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
min-height: 0;
|
||||
padding: var(--space-1) var(--space-3) var(--space-2);
|
||||
overflow: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.bpPopoverFields > * {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.bpPopoverFields .label {
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.bpActions {
|
||||
@@ -123,27 +86,21 @@
|
||||
}
|
||||
|
||||
.bpFooter {
|
||||
flex-wrap: wrap;
|
||||
border-block-start: 1px solid var(--border-popup);
|
||||
}
|
||||
|
||||
.bpFooterButtons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1);
|
||||
margin-inline-start: auto;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.bpMore {
|
||||
.link {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
color: var(--accent);
|
||||
font-size: var(--fs-ui);
|
||||
cursor: pointer;
|
||||
}
|
||||
.bpMore:hover {
|
||||
.link:hover {
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
type CSSProperties,
|
||||
type KeyboardEvent,
|
||||
type MutableRefObject,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
import { basename, relativePath, useProject } from "@/platform/project";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
@@ -138,62 +137,6 @@ function BreakpointPopover() {
|
||||
return <BreakpointEditor key={popover.id} path={popover.path} bp={bp} at={popover} focusLog={popover.focusLog} />;
|
||||
}
|
||||
|
||||
function BreakpointPropertiesPopup({
|
||||
at,
|
||||
title,
|
||||
onClose,
|
||||
onRemove,
|
||||
children,
|
||||
}: {
|
||||
at: { x: number; y: number };
|
||||
title: ReactNode;
|
||||
onClose: () => void;
|
||||
onRemove: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<Popup
|
||||
open
|
||||
onClose={onClose}
|
||||
anchor={at}
|
||||
placement="bottom-start"
|
||||
trapFocus
|
||||
aria-label="Breakpoint properties"
|
||||
className={styles.bpPopover}
|
||||
>
|
||||
<div className={styles.bpPopoverTitle}>{title}</div>
|
||||
<div className={styles.bpPopoverFields}>{children}</div>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.bpMore}
|
||||
onClick={() => {
|
||||
onClose();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.bpFooterButtons}>
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
onRemove();
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={onClose}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
);
|
||||
}
|
||||
|
||||
function BreakpointEditor({
|
||||
path,
|
||||
bp,
|
||||
@@ -212,25 +155,49 @@ function BreakpointEditor({
|
||||
};
|
||||
|
||||
return (
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeBreakpoint(path, bp.id)}
|
||||
title={
|
||||
<>
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<span className={styles.bpDot} data-look={bp.enabled ? "on" : "off"} aria-hidden />
|
||||
<BreakpointLocation path={path} line={bp.line} />
|
||||
</>
|
||||
}
|
||||
>
|
||||
<BreakpointFields
|
||||
path={path}
|
||||
bp={bp}
|
||||
focus={focusLog ? "log" : "condition"}
|
||||
onEnter={close}
|
||||
commitRef={commitText}
|
||||
/>
|
||||
</BreakpointPropertiesPopup>
|
||||
<span className={styles.bpFile}>
|
||||
{basename(path)}:{bp.line + 1}
|
||||
</span>
|
||||
</div>
|
||||
<BreakpointFields
|
||||
path={path}
|
||||
bp={bp}
|
||||
focus={focusLog ? "log" : "condition"}
|
||||
onEnter={close}
|
||||
commitRef={commitText}
|
||||
/>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => {
|
||||
close();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.spacer} />
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
removeBreakpoint(path, bp.id);
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={close}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -398,46 +365,66 @@ function SpecialEditor({ bp, at }: { bp: SpecialBreakpoint; at: { x: number; y:
|
||||
closeBreakpointPopover();
|
||||
};
|
||||
return (
|
||||
<BreakpointPropertiesPopup
|
||||
at={at}
|
||||
onClose={close}
|
||||
onRemove={() => removeSpecial(bp.id)}
|
||||
title={
|
||||
<>
|
||||
<Popup open onClose={close} anchor={at} placement="bottom-start" trapFocus aria-label="Breakpoint properties">
|
||||
<div className={styles.bpEditor}>
|
||||
<div className={styles.bpTitle}>
|
||||
<Icon name={bp.kind === "method" ? "breakpoint-method" : "breakpoint-field"} size={14} />
|
||||
<span className={styles.bpFile} title={specialTitle(bp)}>
|
||||
{specialTitle(bp)}
|
||||
<span className={styles.bpFile}>{specialTitle(bp)}</span>
|
||||
</div>
|
||||
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Condition</T>
|
||||
</span>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Checkbox checked={bp.enabled} onChange={(enabled) => updateSpecial(bp.id, { enabled })} label="Enabled" />
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Condition</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={condition}
|
||||
onChange={(e) => setCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
data-autofocus=""
|
||||
aria-label="Condition"
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Hit count</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={hitCondition}
|
||||
onChange={(e) => setHitCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
aria-label="Hit count condition"
|
||||
/>
|
||||
</label>
|
||||
</BreakpointPropertiesPopup>
|
||||
<Input
|
||||
mono
|
||||
value={condition}
|
||||
onChange={(e) => setCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
data-autofocus=""
|
||||
aria-label="Condition"
|
||||
/>
|
||||
</label>
|
||||
<label className={styles.field}>
|
||||
<span className={styles.label}>
|
||||
<T>Hit count</T>
|
||||
</span>
|
||||
<Input
|
||||
mono
|
||||
value={hitCondition}
|
||||
onChange={(e) => setHitCondition(e.target.value)}
|
||||
onKeyDown={(e) => e.key === "Enter" && close()}
|
||||
aria-label="Hit count condition"
|
||||
/>
|
||||
</label>
|
||||
<div className={styles.bpFooter}>
|
||||
<button
|
||||
type="button"
|
||||
className={styles.link}
|
||||
onClick={() => {
|
||||
close();
|
||||
void executeAction("debug.viewBreakpoints");
|
||||
}}
|
||||
>
|
||||
<T>More</T> <Kbd action="debug.viewBreakpoints" />
|
||||
</button>
|
||||
<div className={styles.spacer} />
|
||||
<Button
|
||||
size="small"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
removeSpecial(bp.id);
|
||||
closeBreakpointPopover();
|
||||
}}
|
||||
>
|
||||
<T>Remove</T>
|
||||
</Button>
|
||||
<Button size="small" variant="primary" onClick={close}>
|
||||
<T>Done</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,39 @@
|
||||
.dialog {
|
||||
height: 500px;
|
||||
height: clamp(320px, 60vh, 760px);
|
||||
}
|
||||
|
||||
/* Scroll only the grid between the toolbar and the expression field. */
|
||||
/* The table scrolls under a fixed bar, not the whole dialog body. */
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
padding: var(--space-2) var(--space-3) 0;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.bar {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
gap: var(--space-2);
|
||||
padding-bottom: var(--space-2);
|
||||
}
|
||||
|
||||
.expression {
|
||||
flex: none;
|
||||
flex: 1 1 200px;
|
||||
min-width: 0;
|
||||
height: var(--h-list-row);
|
||||
padding: 0 6px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-ui);
|
||||
color: var(--fg);
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
}
|
||||
|
||||
.pagers {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
.expression:focus {
|
||||
outline: none;
|
||||
border-color: var(--focus-ring);
|
||||
}
|
||||
|
||||
.summary,
|
||||
@@ -55,8 +59,7 @@
|
||||
.table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
min-width: 100%;
|
||||
font-family: var(--font-ui);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-ui);
|
||||
color: var(--fg);
|
||||
}
|
||||
@@ -74,7 +77,7 @@
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
text-align: center;
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
color: var(--fg-secondary);
|
||||
background: var(--bg-island);
|
||||
@@ -83,8 +86,7 @@
|
||||
.table .index {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
text-align: center;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
font-weight: normal;
|
||||
color: var(--fg-secondary);
|
||||
background: var(--bg-island);
|
||||
@@ -98,22 +100,16 @@
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.numeric {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.dtype {
|
||||
margin-left: var(--space-1);
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
|
||||
.message {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: var(--space-3) 0;
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
|
||||
.error {
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--danger);
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
/** View as Table: a DataFrame / Series / ndarray of the paused frame, one page of rows and columns at a time. */
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import type { DebugSessionId } from "@/platform/ipc";
|
||||
import { Dialog, IconButton, Input } from "@/ui";
|
||||
import { Dialog, IconButton } from "@/ui";
|
||||
import { formatMessage, tx } from "@/platform/i18n";
|
||||
import { evaluate, useDebug } from "../state";
|
||||
import { COLUMN_PAGE, ROW_PAGE, clampWindow, parseTableResult, tableExpression, type TableResult } from "../tableView";
|
||||
import {
|
||||
COLUMN_PAGE,
|
||||
ROW_PAGE,
|
||||
clampWindow,
|
||||
isNumericDtype,
|
||||
parseTableResult,
|
||||
tableExpression,
|
||||
type TableResult,
|
||||
} from "../tableView";
|
||||
import styles from "./TableViewDialog.module.css";
|
||||
|
||||
export function TableViewDialog({
|
||||
@@ -54,7 +63,7 @@ export function TableViewDialog({
|
||||
};
|
||||
}, [expression, win, session, stops, frame, paused]);
|
||||
|
||||
const page = paused && result && "page" in result ? result.page : null;
|
||||
const page = result && "page" in result ? result.page : null;
|
||||
const error = !paused
|
||||
? tx("Values are available while the program is paused")
|
||||
: result && "error" in result
|
||||
@@ -105,37 +114,54 @@ export function TableViewDialog({
|
||||
open
|
||||
onClose={onClose}
|
||||
// An element, not a string: Dialog would translate a variable named like a catalog text ("tasks").
|
||||
title={<span>{expression}</span>}
|
||||
width={700}
|
||||
title={<span>{initial}</span>}
|
||||
width="clamp(520px, 70vw, 1100px)"
|
||||
minWidth={420}
|
||||
minHeight={260}
|
||||
resizable="both"
|
||||
aria-label={formatMessage(tx("Table view of {label}"), { label: expression })}
|
||||
buttons={[{ label: "Close", role: "cancel" }]}
|
||||
aria-label={formatMessage(tx("Table view of {label}"), { label: initial })}
|
||||
className={styles.dialog}
|
||||
>
|
||||
<div className={styles.content}>
|
||||
{page && (
|
||||
<div className={styles.bar}>
|
||||
<div className={styles.bar}>
|
||||
<input
|
||||
className={styles.expression}
|
||||
value={draft}
|
||||
spellCheck={false}
|
||||
autoComplete="off"
|
||||
aria-label={tx("Expression")}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== "Enter" || !draft.trim()) return;
|
||||
e.preventDefault();
|
||||
setExpression(draft.trim());
|
||||
setWin({ row: 0, column: 0 });
|
||||
}}
|
||||
/>
|
||||
{page && (
|
||||
<span className={styles.summary}>
|
||||
{formatMessage(tx("Shape ({shape})"), { shape: page.shape.join(", ") })}
|
||||
{page.kind !== "frame" ? ` · ${page.dtypes[0]}` : ""}
|
||||
</span>
|
||||
<div className={styles.pagers}>
|
||||
{pager(win.row, ROW_PAGE, page.rows, (row) => setWin({ ...win, row }), {
|
||||
range: tx("Rows {from}–{to} of {total}"),
|
||||
previous: tx("Previous Rows"),
|
||||
next: tx("Next Rows"),
|
||||
})}
|
||||
{pager(win.column, COLUMN_PAGE, page.columns, (column) => setWin({ ...win, column }), {
|
||||
range: tx("Columns {from}–{to} of {total}"),
|
||||
previous: tx("Previous Columns"),
|
||||
next: tx("Next Columns"),
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{page &&
|
||||
pager(win.row, ROW_PAGE, page.rows, (row) => setWin({ ...win, row }), {
|
||||
range: tx("Rows {from}–{to} of {total}"),
|
||||
previous: tx("Previous Rows"),
|
||||
next: tx("Next Rows"),
|
||||
})}
|
||||
{page &&
|
||||
pager(win.column, COLUMN_PAGE, page.columns, (column) => setWin({ ...win, column }), {
|
||||
range: tx("Columns {from}–{to} of {total}"),
|
||||
previous: tx("Previous Columns"),
|
||||
next: tx("Next Columns"),
|
||||
})}
|
||||
</div>
|
||||
{error ? (
|
||||
<div className={styles.message} role="alert">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
{page ? (
|
||||
) : page ? (
|
||||
<div className={styles.scroll} tabIndex={0} role="region" aria-label={tx("Table")}>
|
||||
<table className={styles.table}>
|
||||
<thead>
|
||||
@@ -156,7 +182,14 @@ export function TableViewDialog({
|
||||
{page.index[r]}
|
||||
</th>
|
||||
{row.map((cell, c) => (
|
||||
<td key={c}>{cell}</td>
|
||||
<td
|
||||
key={c}
|
||||
className={clsx(
|
||||
isNumericDtype(page.kind === "frame" ? page.dtypes[c] : page.dtypes[0]) && styles.numeric,
|
||||
)}
|
||||
>
|
||||
{cell}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
@@ -164,26 +197,7 @@ export function TableViewDialog({
|
||||
</table>
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.message}>{!error && tx("Loading…")}</div>
|
||||
)}
|
||||
<Input
|
||||
className={styles.expression}
|
||||
mono
|
||||
data-autofocus=""
|
||||
value={draft}
|
||||
aria-label="Expression"
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== "Enter" || !draft.trim()) return;
|
||||
e.preventDefault();
|
||||
setExpression(draft.trim());
|
||||
setWin({ row: 0, column: 0 });
|
||||
}}
|
||||
/>
|
||||
{error && (
|
||||
<div className={styles.error} role="alert">
|
||||
{error}
|
||||
</div>
|
||||
<div className={styles.message}>{tx("Loading…")}</div>
|
||||
)}
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useState } from "react";
|
||||
import { create } from "zustand";
|
||||
import { executeAction, getAction } from "@/platform/actions";
|
||||
import { t, tx } from "@/platform/i18n";
|
||||
import { BarButton, Dialog, Icon, IconButton, List, SplitGroup, SplitHandle, SplitPanel, T } from "@/ui";
|
||||
import { BarButton, Button, Dialog, Icon, List, T } from "@/ui";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { promptInput } from "@/workbench/inputDialogs";
|
||||
import { deleteMacro, describeStep, renameMacro, useMacros } from "./model";
|
||||
@@ -80,55 +80,37 @@ function EditMacrosDialog({ onClose }: { onClose: () => void }) {
|
||||
buttons={[{ label: t("common.close"), role: "cancel" }]}
|
||||
>
|
||||
<div className={styles.edit}>
|
||||
<SplitGroup orientation="horizontal" storageKey="openidea.macros.split" className={styles.panes}>
|
||||
<SplitPanel id="macro-list" defaultSize="50%" minSize="25%">
|
||||
<div className={styles.toolbar} role="toolbar" aria-label={tx("Macros")}>
|
||||
<IconButton
|
||||
icon="minus"
|
||||
title="Delete Macro"
|
||||
size="small"
|
||||
disabled={!macro}
|
||||
onClick={() => void remove()}
|
||||
/>
|
||||
<IconButton
|
||||
icon="edit"
|
||||
title="Rename Macro"
|
||||
size="small"
|
||||
disabled={!macro}
|
||||
onClick={() => void rename()}
|
||||
/>
|
||||
</div>
|
||||
<List
|
||||
items={saved}
|
||||
getKey={(m) => m.name}
|
||||
activeIndex={Math.min(active, saved.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
autoFocus
|
||||
className={styles.list}
|
||||
aria-label="Macros"
|
||||
empty={
|
||||
<div className={styles.empty}>
|
||||
<T>No saved macros</T>
|
||||
</div>
|
||||
}
|
||||
renderItem={(m) => (
|
||||
<div className={styles.row} title={m.name}>
|
||||
{m.name}
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</SplitPanel>
|
||||
<SplitHandle aria-label={tx("Macros")} />
|
||||
<SplitPanel id="macro-steps" defaultSize="50%" minSize="25%">
|
||||
<ol className={styles.steps} aria-label={tx("Recorded steps")}>
|
||||
{macro?.steps.map((step, i) => (
|
||||
<li key={i} className={styles.step}>
|
||||
{describeStep(step, actionTitle)}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</SplitPanel>
|
||||
</SplitGroup>
|
||||
<div className={styles.column}>
|
||||
<List
|
||||
items={saved}
|
||||
getKey={(m) => m.name}
|
||||
activeIndex={Math.min(active, saved.length - 1)}
|
||||
onActiveChange={setActive}
|
||||
className={styles.list}
|
||||
aria-label="Macros"
|
||||
empty={
|
||||
<div className={styles.empty}>
|
||||
<T>No saved macros</T>
|
||||
</div>
|
||||
}
|
||||
renderItem={(m) => <div className={styles.row}>{m.name}</div>}
|
||||
/>
|
||||
<div className={styles.buttons}>
|
||||
<Button disabled={!macro} onClick={() => void rename()}>
|
||||
<T>Rename…</T>
|
||||
</Button>
|
||||
<Button disabled={!macro} onClick={() => void remove()}>
|
||||
<T>Delete</T>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<ol className={styles.steps} aria-label={tx("Recorded steps")}>
|
||||
{macro?.steps.map((step, i) => (
|
||||
<li key={i} className={styles.step}>
|
||||
{describeStep(step, actionTitle)}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -8,27 +8,23 @@
|
||||
background: var(--danger);
|
||||
}
|
||||
.edit {
|
||||
display: grid;
|
||||
grid-template-columns: 220px 1fr;
|
||||
gap: var(--space-3);
|
||||
height: 300px;
|
||||
padding: 14px;
|
||||
}
|
||||
.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 300px;
|
||||
padding: var(--space-3);
|
||||
}
|
||||
.panes {
|
||||
flex: 1;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: var(--space-0-5);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: var(--space-2);
|
||||
min-height: 0;
|
||||
}
|
||||
.list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
}
|
||||
.row {
|
||||
padding: 0 8px;
|
||||
@@ -36,25 +32,27 @@
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.buttons {
|
||||
display: flex;
|
||||
gap: var(--space-1-5);
|
||||
}
|
||||
.empty {
|
||||
padding: 6px 8px;
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.steps {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
padding: var(--space-2) var(--space-2) var(--space-2) 28px;
|
||||
padding: 6px 8px 6px 32px;
|
||||
overflow: auto;
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--fs-ui);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
font-family: var(--font-mono);
|
||||
font-size: var(--fs-code);
|
||||
color: var(--fg);
|
||||
}
|
||||
.step {
|
||||
min-height: var(--h-row);
|
||||
padding-block: var(--space-0-5);
|
||||
line-height: 1.5;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
word-break: break-word;
|
||||
}
|
||||
@@ -1,25 +1,8 @@
|
||||
.renameForm {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
padding: var(--space-3) var(--space-4);
|
||||
}
|
||||
|
||||
.renameName {
|
||||
display: grid;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.renameOptions {
|
||||
.form {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-2) var(--space-4);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.renameOptions > label {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
flex-direction: column;
|
||||
gap: var(--space-2);
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.refactorForm {
|
||||
|
||||
@@ -143,7 +143,7 @@ function Options({
|
||||
disabled: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className={move ? styles.options : styles.renameOptions}>
|
||||
<div className={styles.options}>
|
||||
<Checkbox
|
||||
label="Search for references"
|
||||
checked={value.references}
|
||||
@@ -223,33 +223,31 @@ function RenameDialog({ request }: { request: Extract<FileRefactorRequest, { kin
|
||||
]}
|
||||
>
|
||||
<form
|
||||
className={styles.renameForm}
|
||||
className={styles.form}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
submit();
|
||||
}}
|
||||
>
|
||||
<div className={styles.renameName}>
|
||||
<label className={styles.fieldLabel} htmlFor="file-rename-name">
|
||||
{request.dir
|
||||
? tx`Rename directory '${current}' and its usages to:`
|
||||
: tx`Rename file '${current}' and its usages to:`}
|
||||
</label>
|
||||
<Input
|
||||
id="file-rename-name"
|
||||
ref={input}
|
||||
value={name}
|
||||
disabled={busy}
|
||||
invalid={!!error}
|
||||
aria-label="New name"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
{error && (
|
||||
<div className={styles.error} role="alert">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<label className={styles.fieldLabel} htmlFor="file-rename-name">
|
||||
{request.dir
|
||||
? tx`Rename directory '${current}' and its usages to:`
|
||||
: tx`Rename file '${current}' and its usages to:`}
|
||||
</label>
|
||||
<Input
|
||||
id="file-rename-name"
|
||||
ref={input}
|
||||
value={name}
|
||||
disabled={busy}
|
||||
invalid={!!error}
|
||||
aria-label="New name"
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
/>
|
||||
{error && (
|
||||
<div className={styles.error} role="alert">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
<Options value={options} onChange={setOptions} move={false} disabled={busy} />
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
import { useMemo, useRef, useState, type KeyboardEvent } from "react";
|
||||
import { useMemo, useState, type KeyboardEvent } from "react";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
HighlightedText,
|
||||
Icon,
|
||||
List,
|
||||
Popup,
|
||||
SearchField,
|
||||
firstSelectable,
|
||||
fuzzyMatch,
|
||||
listNavigate,
|
||||
T,
|
||||
type PopupAnchor,
|
||||
} from "@/ui";
|
||||
import { HighlightedText, Icon, List, Popup, SearchField, fuzzyMatch, listNavigate, T, type PopupAnchor } from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { useRunConfigTypes, runConfigTypes, type RunConfigTypeContribution } from "@/workbench/contributions";
|
||||
import styles from "./Run.module.css";
|
||||
@@ -75,11 +64,12 @@ export function AddConfigPopup({
|
||||
const [query, setQuery] = useState("");
|
||||
const rows = useMemo(() => typeRows(runConfigTypes(types), query), [types, query]);
|
||||
const isSection = (r: TypeRow) => r.kind === "group";
|
||||
const [active, setActive] = useState(-1);
|
||||
const first = Math.max(
|
||||
0,
|
||||
rows.findIndex((r) => r.kind === "type"),
|
||||
);
|
||||
const [active, setActive] = useState(first);
|
||||
const clamped = Math.min(active, rows.length - 1);
|
||||
const selected = rows[clamped]?.kind === "type" ? clamped : firstSelectable(rows, isSection);
|
||||
const viewport = useRef<HTMLDivElement>(null);
|
||||
const height = Math.max(1, Math.min(rows.length, 30)) * rowHeight;
|
||||
|
||||
const pick = (row: TypeRow | undefined) => {
|
||||
if (row?.kind !== "type") return;
|
||||
@@ -90,11 +80,10 @@ export function AddConfigPopup({
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
pick(rows[selected]);
|
||||
pick(rows[clamped]);
|
||||
return;
|
||||
}
|
||||
const pageSize = Math.max(1, Math.floor((viewport.current?.clientHeight ?? height) / rowHeight) - 1);
|
||||
const next = listNavigate(e.key, { items: rows, active: selected, isSection, pageSize, wrap: true });
|
||||
const next = listNavigate(e.key, { items: rows, active: clamped, isSection, wrap: true });
|
||||
if (next !== null) {
|
||||
e.preventDefault();
|
||||
setActive(next);
|
||||
@@ -108,7 +97,7 @@ export function AddConfigPopup({
|
||||
onClose={onClose}
|
||||
placement="bottom-start"
|
||||
aria-label="Add New Configuration"
|
||||
className={clsx(styles.chooser, styles.typeChooser)}
|
||||
className={styles.chooser}
|
||||
trapFocus
|
||||
>
|
||||
<div className={styles.chooserCaption}>
|
||||
@@ -119,7 +108,7 @@ export function AddConfigPopup({
|
||||
value={query}
|
||||
onChange={(v) => {
|
||||
setQuery(v);
|
||||
setActive(-1);
|
||||
setActive(0);
|
||||
}}
|
||||
placeholder="Search types"
|
||||
aria-label="Search configuration types"
|
||||
@@ -128,7 +117,7 @@ export function AddConfigPopup({
|
||||
variant="bare"
|
||||
/>
|
||||
</div>
|
||||
<div ref={viewport} className={styles.chooserViewport} style={{ height }}>
|
||||
<div style={{ height: Math.max(rowHeight, Math.min(rows.length * rowHeight, 14 * rowHeight)) }}>
|
||||
<List<TypeRow>
|
||||
aria-label="Configuration types"
|
||||
className={styles.chooserList}
|
||||
@@ -136,7 +125,7 @@ export function AddConfigPopup({
|
||||
getKey={(r) => r.key}
|
||||
isSection={isSection}
|
||||
renderSection={(r) => (r.kind === "group" ? r.label : null)}
|
||||
activeIndex={selected}
|
||||
activeIndex={rows[clamped]?.kind === "type" ? clamped : first}
|
||||
onActiveChange={setActive}
|
||||
focusable={false}
|
||||
hoverSelects
|
||||
@@ -150,7 +139,7 @@ export function AddConfigPopup({
|
||||
renderItem={(r) =>
|
||||
r.kind === "type" ? (
|
||||
<span className={clsx(styles.chooserRow, r.nested && styles.typeNested)} title={r.type.description}>
|
||||
<Icon name={r.type.icon} size={16} className={styles.chooserIcon} />
|
||||
<Icon name={r.type.icon} size={13} className={styles.chooserIcon} />
|
||||
<span className={styles.chooserName}>
|
||||
{r.indices?.length ? <HighlightedText text={r.type.label} indices={r.indices} /> : r.type.label}
|
||||
</span>
|
||||
|
||||
+57
-118
@@ -6,16 +6,7 @@
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { isJvmApplication, parseJavaArgs } from "@/platform/javaLaunch";
|
||||
import { useRunTargets } from "@/platform/pluginRunTargets";
|
||||
import {
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
type KeyboardEvent,
|
||||
type MouseEvent,
|
||||
type ReactNode,
|
||||
type RefObject,
|
||||
} from "react";
|
||||
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode, type RefObject } from "react";
|
||||
import clsx from "clsx";
|
||||
import { isTauri, type BeforeLaunchTask, type BuildPolicy, type RunConfig } from "@/platform/ipc";
|
||||
import { useWorkflowSettings } from "@/platform/workflowSettings";
|
||||
@@ -63,16 +54,6 @@ import { TomcatSettings } from "./TomcatSettings";
|
||||
import { toolWindowTitle } from "@/workbench/toolwindows/title";
|
||||
import styles from "./Run.module.css";
|
||||
|
||||
const TASK_ICONS: Readonly<Partial<Record<string, string>>> = {
|
||||
build: "build-project",
|
||||
buildModule: "build-project",
|
||||
buildArtifacts: "build-rebuild",
|
||||
dotnetBuild: "build-project",
|
||||
run: "run",
|
||||
tool: "settings",
|
||||
command: "terminal",
|
||||
};
|
||||
|
||||
/**
|
||||
* Debug adapters with a real launch template (`debugger/launch.ts`, `debugger/java.ts`),
|
||||
* verified against small programs. Others (dart, …) only got
|
||||
@@ -351,7 +332,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
const [envOpen, setEnvOpen] = useState(false);
|
||||
const [modifyOpen, setModifyOpen] = useState(false);
|
||||
const [lastRequest, setLastRequest] = useState(modifyRequest);
|
||||
const [taskMenu, setTaskMenu] = useState<"add" | { index: number; anchor: HTMLButtonElement } | null>(null);
|
||||
const [taskMenu, setTaskMenu] = useState(false);
|
||||
const modifyRef = useRef<HTMLButtonElement>(null);
|
||||
const taskRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
@@ -425,23 +406,23 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
run: () => addTask("run", c.id),
|
||||
})),
|
||||
},
|
||||
{ label: TASK_LABELS.build, icon: TASK_ICONS.build, run: () => addTask("build") },
|
||||
{ label: TASK_LABELS.build, icon: "build-project", run: () => addTask("build") },
|
||||
{
|
||||
label: TASK_LABELS.buildModule,
|
||||
icon: TASK_ICONS.buildModule,
|
||||
icon: "build-project",
|
||||
disabled: config.module == null,
|
||||
run: () => addTask("buildModule", config.module ?? ""),
|
||||
},
|
||||
{ label: TASK_LABELS.buildArtifacts, icon: TASK_ICONS.buildArtifacts, run: () => addTask("buildArtifacts") },
|
||||
{ label: TASK_LABELS.buildArtifacts, icon: "build-rebuild", run: () => addTask("buildArtifacts") },
|
||||
...(config.kind === "dotnet"
|
||||
? [{ label: TASK_LABELS.dotnetBuild, icon: TASK_ICONS.dotnetBuild, run: () => addTask("dotnetBuild") }]
|
||||
? [{ label: TASK_LABELS.dotnetBuild, icon: "build-project", run: () => addTask("dotnetBuild") }]
|
||||
: []),
|
||||
{
|
||||
label: TASK_LABELS.tool,
|
||||
disabled: !externalTools.length,
|
||||
submenu: externalTools.map((t) => ({ label: t.name, verbatim: true, run: () => addTask("tool", t.id) })),
|
||||
},
|
||||
{ label: TASK_LABELS.command, icon: TASK_ICONS.command, run: () => addTask("command") },
|
||||
{ label: TASK_LABELS.command, icon: "terminal", run: () => addTask("command") },
|
||||
{
|
||||
label: TASK_LABELS.toolWindow,
|
||||
submenu: [...toolWindows.values()]
|
||||
@@ -461,7 +442,6 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
[next[i], next[j]] = [next[j]!, next[i]!];
|
||||
setTasks(next);
|
||||
};
|
||||
const taskActions = taskMenu === "add" ? null : taskMenu;
|
||||
|
||||
const adapterOptions: SelectOption[] = [
|
||||
{ value: "", label: "None" },
|
||||
@@ -783,103 +763,62 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
|
||||
|
||||
{isShown("beforeLaunch") && (
|
||||
<Field label="Before launch" error={errors.beforeLaunch} top>
|
||||
<div className={styles.beforeLaunchTasks} role="list" aria-label={tx("Before launch tasks")}>
|
||||
{tasks.map((t, i) => {
|
||||
const label = txTemplate(taskLabel(t, all));
|
||||
const target = t.kind === "run" ? all.find((c) => c.id === t.target) : undefined;
|
||||
const icon = target ? configIcon(target) : TASK_ICONS[t.kind];
|
||||
const prefix = (
|
||||
<>
|
||||
{icon && <Icon name={icon} size={14} />}
|
||||
<span className={styles.taskOrder}>{i + 1}.</span>
|
||||
</>
|
||||
);
|
||||
const actions = {
|
||||
"aria-haspopup": "menu" as const,
|
||||
"aria-expanded": taskActions?.index === i,
|
||||
onClick: (e: MouseEvent<HTMLButtonElement>) => setTaskMenu({ index: i, anchor: e.currentTarget }),
|
||||
};
|
||||
return (
|
||||
<div key={i} role="listitem" className={styles.taskTag}>
|
||||
{t.kind === "command" ? (
|
||||
<>
|
||||
{prefix}
|
||||
<Input
|
||||
mono
|
||||
className={styles.taskCommand}
|
||||
aria-label={txTemplate(`Before launch command ${i + 1}`)}
|
||||
value={t.target ?? ""}
|
||||
placeholder="Shell command, e.g. make generate"
|
||||
onChange={(e) =>
|
||||
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
|
||||
}
|
||||
/>
|
||||
<IconButton icon="more" title="Task Actions" size="small" {...actions} />
|
||||
</>
|
||||
) : (
|
||||
<button type="button" className={styles.taskName} title={label} {...actions}>
|
||||
{prefix}
|
||||
<span className={styles.taskLabel}>{label}</span>
|
||||
</button>
|
||||
)}
|
||||
<div className={styles.taskList} role="list" aria-label={tx("Before launch tasks")}>
|
||||
{tasks.map((t, i) => (
|
||||
<div key={i} role="listitem" className={styles.taskRow}>
|
||||
{t.kind === "command" ? (
|
||||
<Input
|
||||
mono
|
||||
aria-label={txTemplate(`Before launch command ${i + 1}`)}
|
||||
value={t.target ?? ""}
|
||||
placeholder="Shell command, e.g. make generate"
|
||||
onChange={(e) =>
|
||||
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<span className={styles.taskLabel} title={txTemplate(taskLabel(t, all))}>
|
||||
{txTemplate(taskLabel(t, all))}
|
||||
</span>
|
||||
)}
|
||||
<span className={styles.taskActions}>
|
||||
<IconButton
|
||||
icon="close"
|
||||
icon="arrow-up"
|
||||
size="small"
|
||||
iconSize={12}
|
||||
title="Move Up"
|
||||
disabled={i === 0}
|
||||
onClick={() => moveTask(i, -1)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="arrow-down"
|
||||
size="small"
|
||||
iconSize={12}
|
||||
title="Move Down"
|
||||
disabled={i === tasks.length - 1}
|
||||
onClick={() => moveTask(i, 1)}
|
||||
/>
|
||||
<IconButton
|
||||
icon="minus"
|
||||
size="small"
|
||||
iconSize={12}
|
||||
title="Remove Task"
|
||||
onClick={() => setTasks(tasks.filter((_, j) => j !== i))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div role="listitem">
|
||||
{tasks.length ? (
|
||||
<IconButton
|
||||
ref={taskRef}
|
||||
title="Add task"
|
||||
icon="plus"
|
||||
size="small"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={taskMenu === "add"}
|
||||
onClick={() => setTaskMenu("add")}
|
||||
/>
|
||||
) : (
|
||||
<Button
|
||||
ref={taskRef}
|
||||
size="small"
|
||||
variant="ghost"
|
||||
icon="plus"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={taskMenu === "add"}
|
||||
onClick={() => setTaskMenu("add")}
|
||||
>
|
||||
<T>Add task</T>
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
<Menu open={taskMenu === "add"} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(null)} />
|
||||
{taskActions && (
|
||||
<Menu
|
||||
open
|
||||
anchor={taskActions.anchor}
|
||||
aria-label={tx("Task Actions")}
|
||||
items={[
|
||||
{
|
||||
label: "Move Up",
|
||||
icon: "arrow-up",
|
||||
disabled: taskActions.index === 0,
|
||||
run: () => moveTask(taskActions.index, -1),
|
||||
},
|
||||
{
|
||||
label: "Move Down",
|
||||
icon: "arrow-down",
|
||||
disabled: taskActions.index === tasks.length - 1,
|
||||
run: () => moveTask(taskActions.index, 1),
|
||||
},
|
||||
]}
|
||||
onClose={() => setTaskMenu(null)}
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
<Button
|
||||
ref={taskRef}
|
||||
size="small"
|
||||
variant="ghost"
|
||||
icon="plus"
|
||||
aria-haspopup="menu"
|
||||
onClick={() => setTaskMenu(true)}
|
||||
>
|
||||
<T>Add task</T>
|
||||
</Button>
|
||||
<Menu open={taskMenu} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(false)} />
|
||||
</div>
|
||||
</Field>
|
||||
)}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useRef, useState, type RefObject } from "react";
|
||||
import { useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { isImeKey } from "@/platform/ime";
|
||||
import { Button, IconButton, Popup } from "@/ui";
|
||||
import { Dialog, IconButton } from "@/ui";
|
||||
import styles from "./Run.module.css";
|
||||
|
||||
/**
|
||||
@@ -26,10 +25,9 @@ export function ExpandableTextarea({
|
||||
onChange: (value: string) => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const fieldRef = useRef<HTMLDivElement>(null);
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
return (
|
||||
<div ref={fieldRef} className={styles.textareaWithButton}>
|
||||
<div className={styles.textareaWithButton}>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, invalid && styles.textareaInvalid)}
|
||||
aria-label={tx(label)}
|
||||
@@ -45,86 +43,58 @@ export function ExpandableTextarea({
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<IconButton
|
||||
icon="expand-all"
|
||||
size="small"
|
||||
iconSize={14}
|
||||
title="Expand (⇧⏎)"
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={expanded}
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
/>
|
||||
<IconButton icon="expand-all" size="small" iconSize={14} title="Expand (⇧⏎)" onClick={() => setExpanded(true)} />
|
||||
{expanded && (
|
||||
<ExpandedTextPopup
|
||||
anchor={fieldRef}
|
||||
label={tx(label)}
|
||||
value={value}
|
||||
onOk={onChange}
|
||||
onClose={() => setExpanded(false)}
|
||||
/>
|
||||
<ExpandedTextDialog label={label} value={value} onOk={onChange} onClose={() => setExpanded(false)} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ExpandedTextPopup({
|
||||
anchor,
|
||||
function ExpandedTextDialog({
|
||||
label,
|
||||
value,
|
||||
onOk,
|
||||
onClose,
|
||||
}: {
|
||||
anchor: RefObject<HTMLDivElement | null>;
|
||||
label: string;
|
||||
value: string;
|
||||
onOk: (value: string) => void;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const tx = useTx();
|
||||
const [text, setText] = useState(value);
|
||||
const apply = () => {
|
||||
if (text !== value) onOk(text);
|
||||
onClose();
|
||||
};
|
||||
return (
|
||||
<Popup
|
||||
<Dialog
|
||||
open
|
||||
anchor={anchor}
|
||||
aria-label={label}
|
||||
className={styles.expandedEditor}
|
||||
title={tx(label)}
|
||||
onClose={onClose}
|
||||
trapFocus
|
||||
matchWidth
|
||||
closeOnDeactivate={false}
|
||||
width={720}
|
||||
resizable="both"
|
||||
minWidth={240}
|
||||
minHeight={160}
|
||||
minWidth={360}
|
||||
minHeight={220}
|
||||
buttons={[
|
||||
{
|
||||
label: "OK",
|
||||
role: "default",
|
||||
onClick: () => {
|
||||
if (text !== value) onOk(text);
|
||||
onClose();
|
||||
},
|
||||
},
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div
|
||||
className={styles.expandedEditorBody}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key !== "Enter" || !(e.ctrlKey || e.metaKey) || e.altKey || e.shiftKey || isImeKey(e.nativeEvent))
|
||||
return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
apply();
|
||||
}}
|
||||
>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, styles.expandedTextarea)}
|
||||
aria-label={label}
|
||||
spellCheck={false}
|
||||
wrap="off"
|
||||
value={text}
|
||||
data-autofocus
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
<div className={styles.expandedEditorActions}>
|
||||
<Button onClick={onClose}>Cancel</Button>
|
||||
<Button variant="primary" onClick={apply}>
|
||||
OK
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Popup>
|
||||
<textarea
|
||||
className={clsx(styles.textarea, styles.expandedTextarea)}
|
||||
aria-label={tx(label)}
|
||||
spellCheck={false}
|
||||
wrap="off"
|
||||
rows={14}
|
||||
value={text}
|
||||
autoFocus
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { commands } from "@/platform/ipc";
|
||||
import { ExportTestResultsDialog, defaultExportName, loadExportOptions } from "./ExportTestResultsDialog";
|
||||
import { ExportTestResultsDialog, defaultExportPath, loadExportOptions } from "./ExportTestResultsDialog";
|
||||
import { TestResults } from "./testing";
|
||||
|
||||
const actions = vi.hoisted(() => ({ executeAction: vi.fn(async () => {}) }));
|
||||
@@ -56,15 +56,13 @@ function open(onClose = vi.fn()) {
|
||||
return onClose;
|
||||
}
|
||||
|
||||
const file = () => screen.getByLabelText("File name");
|
||||
const folder = () => screen.getByLabelText("Folder");
|
||||
const file = () => screen.getByLabelText("Output file");
|
||||
const press = (name: string) => fireEvent.click(screen.getByRole("button", { name }));
|
||||
|
||||
describe("ExportTestResultsDialog", () => {
|
||||
it("writes an HTML report to the project folder and opens it in the browser", async () => {
|
||||
it("writes an HTML report to the project folder under IDEA's name and opens it in the browser", async () => {
|
||||
const onClose = open();
|
||||
expect(file()).toHaveValue("Test Results - go test _calc.html");
|
||||
expect(folder()).toHaveValue("/work/app/");
|
||||
expect(file()).toHaveValue("/work/app/Test Results - go test _calc.html");
|
||||
expect(screen.getByRole("radio", { name: "HTML" })).toBeChecked();
|
||||
press("OK");
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled());
|
||||
@@ -94,7 +92,7 @@ describe("ExportTestResultsDialog", () => {
|
||||
it("switches the extension with the format, keeps XML out of the browser, and remembers the choice", async () => {
|
||||
const onClose = open();
|
||||
fireEvent.click(screen.getByRole("radio", { name: "XML" }));
|
||||
expect(file()).toHaveValue("Test Results - go test _calc.xml");
|
||||
expect(file()).toHaveValue("/work/app/Test Results - go test _calc.xml");
|
||||
// Only an HTML report opens in the browser.
|
||||
expect(screen.getByRole("checkbox", { name: "Open exported file in browser" })).toBeDisabled();
|
||||
press("OK");
|
||||
@@ -145,36 +143,18 @@ describe("ExportTestResultsDialog", () => {
|
||||
});
|
||||
|
||||
it("doesn't ask again for a file the save dialog already confirmed", async () => {
|
||||
const path = "C:\\reports\\picked.html";
|
||||
onDisk[path] = "file";
|
||||
dialog.save.mockResolvedValueOnce(path);
|
||||
onDisk["/tmp/picked.html"] = "file";
|
||||
dialog.save.mockResolvedValueOnce("/tmp/picked.html");
|
||||
const onClose = open();
|
||||
press("Browse…");
|
||||
await waitFor(() => expect(file()).toHaveValue("picked.html"));
|
||||
expect(folder()).toHaveValue("C:\\reports\\");
|
||||
await waitFor(() => expect(file()).toHaveValue("/tmp/picked.html"));
|
||||
expect(dialog.save).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
defaultPath: "/work/app/Test Results - go test _calc.html",
|
||||
filters: [{ name: "HTML", extensions: ["html"] }],
|
||||
}),
|
||||
expect.objectContaining({ filters: [{ name: "HTML", extensions: ["html"] }] }),
|
||||
);
|
||||
press("OK");
|
||||
await waitFor(() => expect(onClose).toHaveBeenCalled());
|
||||
expect(messages.confirm).not.toHaveBeenCalled();
|
||||
expect(written.map((w) => w.path)).toEqual([path]);
|
||||
});
|
||||
|
||||
it("confirms again when the destination changes after using the save dialog", async () => {
|
||||
dialog.save.mockResolvedValueOnce("/tmp/picked.html");
|
||||
onDisk["/work/app/reports/picked.html"] = "file";
|
||||
messages.confirm.mockResolvedValueOnce(false);
|
||||
open();
|
||||
press("Browse…");
|
||||
await waitFor(() => expect(file()).toHaveValue("picked.html"));
|
||||
fireEvent.change(folder(), { target: { value: "reports" } });
|
||||
press("OK");
|
||||
await waitFor(() => expect(messages.confirm).toHaveBeenCalledOnce());
|
||||
expect(written).toHaveLength(0);
|
||||
expect(written.map((w) => w.path)).toEqual(["/tmp/picked.html"]);
|
||||
});
|
||||
|
||||
it("reports a directory or a failed write and stays open", async () => {
|
||||
@@ -207,11 +187,15 @@ describe("ExportTestResultsDialog", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("defaultExportName", () => {
|
||||
describe("defaultExportPath", () => {
|
||||
it("replaces characters file systems refuse in the configuration's name", () => {
|
||||
expect(defaultExportName('a/b\\c:d*e?f"g<h>i|j', "xml")).toBe("Test Results - a_b_c_d_e_f_g_h_i_j.xml");
|
||||
expect(defaultExportName("go test ./...", "html")).toBe("Test Results - go test.html");
|
||||
expect(defaultExportName("Tests in 'com.acme.Cart'", "html")).toBe("Test Results - Tests in 'com_acme_Cart'.html");
|
||||
expect(defaultExportName("...", "html")).toBe("Test Results - Tests.html");
|
||||
expect(defaultExportPath("C:\\proj\\", 'a/b\\c:d*e?f"g<h>i|j', "xml")).toBe(
|
||||
"C:\\proj/Test Results - a_b_c_d_e_f_g_h_i_j.xml",
|
||||
);
|
||||
expect(defaultExportPath("/p", "go test ./...", "html")).toBe("/p/Test Results - go test.html");
|
||||
expect(defaultExportPath("/p", "Tests in 'com.acme.Cart'", "html")).toBe(
|
||||
"/p/Test Results - Tests in 'com_acme_Cart'.html",
|
||||
);
|
||||
expect(defaultExportPath("/p", "...", "html")).toBe("/p/Test Results - Tests.html");
|
||||
});
|
||||
});
|
||||
@@ -2,7 +2,7 @@
|
||||
* IDEA's Export Test Results dialog: HTML or XML, the output file, and whether to
|
||||
* open an HTML report in the browser once it is written.
|
||||
*/
|
||||
import { useId, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
@@ -38,35 +38,13 @@ function saveExportOptions(o: ExportOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Runs of dots and characters file systems refuse become one `_`. */
|
||||
export function defaultExportName(name: string, format: TestExportFormat): string {
|
||||
/**
|
||||
* IDEA's default name, `Test Results - <configuration>.html`. Like IDEA's `PathUtil.suggestFileName`, runs of
|
||||
* dots and characters file systems refuse become one `_` (`go test ./...` gives `go test`).
|
||||
*/
|
||||
export function defaultExportPath(dir: string, name: string, format: TestExportFormat): string {
|
||||
const safe = name.replace(/[/\\:*?"<>|.]+/g, "_").replace(/^[\s_]+|[\s_]+$/g, "");
|
||||
return `Test Results - ${safe || "Tests"}.${format}`;
|
||||
}
|
||||
|
||||
interface Destination {
|
||||
folder: string;
|
||||
fileName: string;
|
||||
/** The native picker already asked before replacing this exact path. */
|
||||
pickedPath?: string;
|
||||
}
|
||||
|
||||
function destinationFromPicker(path: string): Destination {
|
||||
const slash = path.lastIndexOf("/");
|
||||
const posix = path.startsWith("/") && !path.startsWith("//");
|
||||
const end = (posix ? slash : Math.max(slash, path.lastIndexOf("\\"))) + 1;
|
||||
return { folder: path.slice(0, end), fileName: path.slice(end), pickedPath: path };
|
||||
}
|
||||
|
||||
function resolveDestination({ folder, fileName, pickedPath }: Destination, cwd: string): string {
|
||||
if (pickedPath) return pickedPath;
|
||||
const file = fileName.trim();
|
||||
if (!file || isAbsolutePath(file)) return file;
|
||||
const dir = folder.trim();
|
||||
const posix = dir.startsWith("/") && !dir.startsWith("//");
|
||||
const base = dir.replace(posix ? /\/+$/ : /[\\/]+$/, "");
|
||||
const path = dir ? `${base}/${file}` : file;
|
||||
return isAbsolutePath(path) ? path : `${cwd.replace(/[\\/]+$/, "")}/${path}`;
|
||||
return `${dir.replace(/[\\/]+$/, "")}/Test Results - ${safe || "Tests"}.${format}`;
|
||||
}
|
||||
|
||||
async function exists(path: string): Promise<"file" | "dir" | null> {
|
||||
@@ -133,47 +111,44 @@ export function ExportTestResultsDialog({
|
||||
cwd: string;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const fileNameId = useId();
|
||||
const folderId = useId();
|
||||
const [options, setOptions] = useState(loadExportOptions);
|
||||
const [destination, setDestination] = useState<Destination>(() => ({
|
||||
folder: cwd,
|
||||
fileName: defaultExportName(name, options.format),
|
||||
}));
|
||||
const [path, setPath] = useState(() => defaultExportPath(cwd, name, options.format));
|
||||
// The save dialog already asked before replacing this file.
|
||||
const [picked, setPicked] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const html = options.format === "html";
|
||||
const { folder, fileName, pickedPath } = destination;
|
||||
const target = resolveDestination(destination, cwd);
|
||||
|
||||
const update = (next: Partial<ExportOptions>) => {
|
||||
const merged = { ...options, ...next };
|
||||
setOptions(merged);
|
||||
saveExportOptions(merged);
|
||||
// The file follows the format's extension, as in the Export Data dialog.
|
||||
if (next.format) {
|
||||
const nextName = fileName.replace(/\.(html|xml)$/i, `.${next.format}`);
|
||||
if (nextName !== fileName) setDestination({ folder, fileName: nextName });
|
||||
}
|
||||
if (next.format) setPath((p) => p.replace(/\.(html|xml)$/i, `.${next.format}`));
|
||||
};
|
||||
|
||||
const browse = async () => {
|
||||
try {
|
||||
const { save } = await import("@/platform/dialog");
|
||||
const chosen = await save({
|
||||
defaultPath: target || folder || cwd,
|
||||
defaultPath: path,
|
||||
filters: [{ name: html ? "HTML" : "XML", extensions: [options.format] }],
|
||||
});
|
||||
if (chosen) setDestination(destinationFromPicker(chosen));
|
||||
if (chosen) {
|
||||
setPath(chosen);
|
||||
setPicked(chosen);
|
||||
}
|
||||
} catch {
|
||||
// No dialog (tests): keep typing the path.
|
||||
}
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
if (!target) return;
|
||||
const raw = path.trim();
|
||||
if (!raw) return;
|
||||
const target = isAbsolutePath(raw) ? raw : `${cwd.replace(/[\\/]+$/, "")}/${raw}`;
|
||||
setBusy(true);
|
||||
const text = exportTestResults(options.format, results, { name, cwd, date: new Date() });
|
||||
const ok = await writeTestReport(target, text, pickedPath !== undefined);
|
||||
const ok = await writeTestReport(target, text, picked === raw);
|
||||
setBusy(false);
|
||||
if (!ok) return;
|
||||
onClose();
|
||||
@@ -192,46 +167,29 @@ export function ExportTestResultsDialog({
|
||||
open
|
||||
title="Export Test Results"
|
||||
onClose={onClose}
|
||||
width={500}
|
||||
width={520}
|
||||
buttons={[
|
||||
{ label: "OK", role: "default", disabled: busy || !target, onClick: () => void run() },
|
||||
{ label: "OK", role: "default", disabled: busy || !path.trim(), onClick: () => void run() },
|
||||
{ label: "Cancel", role: "cancel" },
|
||||
]}
|
||||
>
|
||||
<div className={styles.exportReport}>
|
||||
<fieldset className={styles.exportFormats} role="radiogroup">
|
||||
<legend>
|
||||
<div className={styles.dialogBody}>
|
||||
<div className={styles.exportFormats} role="radiogroup" aria-label="Export format">
|
||||
<span>
|
||||
<T>Export format:</T>
|
||||
</legend>
|
||||
</span>
|
||||
<Radio name="test-export-format" label="HTML" checked={html} onChange={() => update({ format: "html" })} />
|
||||
<Radio name="test-export-format" label="XML" checked={!html} onChange={() => update({ format: "xml" })} />
|
||||
</fieldset>
|
||||
<fieldset className={styles.exportOutput}>
|
||||
<legend>
|
||||
<T>Output</T>
|
||||
</legend>
|
||||
<label htmlFor={fileNameId}>
|
||||
<T>File name</T>
|
||||
</label>
|
||||
<Input
|
||||
id={fileNameId}
|
||||
autoSelect
|
||||
data-autofocus=""
|
||||
value={fileName}
|
||||
onChange={(e) => setDestination({ folder, fileName: e.target.value })}
|
||||
/>
|
||||
<label htmlFor={folderId}>
|
||||
<T>Folder</T>
|
||||
</label>
|
||||
</div>
|
||||
<label className={styles.exportField}>
|
||||
<span>
|
||||
<T>Output file:</T>
|
||||
</span>
|
||||
<div className={styles.inputWithButton}>
|
||||
<Input
|
||||
id={folderId}
|
||||
value={folder}
|
||||
onChange={(e) => setDestination({ folder: e.target.value, fileName })}
|
||||
/>
|
||||
<Input mono aria-label="Output file" value={path} onChange={(e) => setPath(e.target.value)} />
|
||||
<IconButton icon="folder" title="Browse…" onClick={() => void browse()} />
|
||||
</div>
|
||||
</fieldset>
|
||||
</label>
|
||||
<Checkbox
|
||||
checked={html && options.openInBrowser}
|
||||
disabled={!html}
|
||||
|
||||
+17
-107
@@ -560,17 +560,6 @@
|
||||
color: var(--fg-secondary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.typeChooser {
|
||||
width: 280px;
|
||||
}
|
||||
.typeChooser .chooserCaption {
|
||||
padding: var(--space-2) var(--space-3) 0;
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
.typeChooser .chooserSearch {
|
||||
padding: var(--space-1) var(--space-3);
|
||||
}
|
||||
.chooserMnemonic {
|
||||
flex: none;
|
||||
width: 8px;
|
||||
@@ -922,44 +911,28 @@
|
||||
outline: none;
|
||||
}
|
||||
.textareaWithButton {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
}
|
||||
.textareaWithButton > textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding-inline-end: calc(var(--space-3) + var(--space-4));
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.textareaWithButton > button {
|
||||
position: absolute;
|
||||
inset-block-start: var(--space-1);
|
||||
inset-inline-end: var(--space-1);
|
||||
}
|
||||
.expandedEditor {
|
||||
width: 512px;
|
||||
height: 272px;
|
||||
}
|
||||
.expandedEditorBody {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
padding: var(--space-2);
|
||||
gap: var(--space-2);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* One visual line per line of text: a long argument scrolls instead of wrapping. */
|
||||
.expandedTextarea {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 160px;
|
||||
box-sizing: border-box;
|
||||
resize: none;
|
||||
white-space: pre;
|
||||
overflow: auto;
|
||||
}
|
||||
.expandedEditorActions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
flex: none;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.textarea:focus {
|
||||
box-shadow: inset 0 0 0 1px var(--focus-ring);
|
||||
}
|
||||
@@ -985,43 +958,10 @@
|
||||
.taskRow > :first-child {
|
||||
min-width: 0;
|
||||
}
|
||||
.beforeLaunchTasks {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.taskTag {
|
||||
.taskActions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
min-height: var(--h-list-row);
|
||||
padding-inline: var(--space-2) var(--space-1);
|
||||
border-radius: var(--radius-small);
|
||||
background: var(--bg-elev);
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.taskName {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1);
|
||||
min-width: 0;
|
||||
min-height: var(--h-list-row);
|
||||
text-align: start;
|
||||
}
|
||||
.taskName:hover {
|
||||
color: var(--fg-strong);
|
||||
}
|
||||
.taskOrder {
|
||||
flex: none;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.taskTag .taskCommand {
|
||||
width: 24ch;
|
||||
height: var(--h-control-small);
|
||||
gap: var(--space-0-5);
|
||||
}
|
||||
.taskLabel {
|
||||
overflow: hidden;
|
||||
@@ -1194,48 +1134,18 @@
|
||||
gap: var(--space-2);
|
||||
padding: 12px 16px;
|
||||
}
|
||||
.exportReport {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-3) var(--space-4) var(--space-1);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.exportFormats,
|
||||
.exportOutput {
|
||||
min-inline-size: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.exportReport legend {
|
||||
margin-block-end: var(--space-2);
|
||||
padding: 0;
|
||||
color: var(--fg-strong);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.exportFormats {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: var(--space-1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
}
|
||||
|
||||
.exportOutput {
|
||||
.exportField {
|
||||
display: grid;
|
||||
grid-template-columns: max-content minmax(0, 1fr);
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.exportOutput > label {
|
||||
max-inline-size: 120px;
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
/* Folded console lines ("<N internal lines>"). */
|
||||
.fold {
|
||||
color: var(--fg-fold-placeholder);
|
||||
|
||||
@@ -375,8 +375,7 @@ describe("Export Test Results", () => {
|
||||
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
act(() => testTree.exportResults!());
|
||||
expect(screen.getByRole("dialog", { name: "Export Test Results" })).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("File name")).toHaveValue("Test Results - calc tests.html");
|
||||
expect(screen.getByLabelText("Folder")).toHaveValue("/p");
|
||||
expect(screen.getByLabelText("Output file")).toHaveValue("/p/Test Results - calc tests.html");
|
||||
fireEvent.click(screen.getByRole("button", { name: "Cancel" }));
|
||||
expect(screen.queryByRole("dialog", { name: "Export Test Results" })).toBeNull();
|
||||
unmount();
|
||||
|
||||
@@ -262,7 +262,6 @@ export function choiceItems(choices: readonly Produced[], debug: boolean): MenuI
|
||||
{ kind: "header", label: debug ? "Choose configuration to debug" : "Choose configuration to run" },
|
||||
...choices.map((p): MenuItem => ({
|
||||
label: debug ? tx`Debug '${p.name}'` : tx`Run '${p.name}'`,
|
||||
preserveLabelEnd: true,
|
||||
verbatim: true,
|
||||
icon: debug ? "debug" : "run",
|
||||
shortcut: p.detail,
|
||||
|
||||
@@ -82,7 +82,6 @@ async function profileMenu(entry: ScriptEntry, path: string): Promise<MenuItem[]
|
||||
return [
|
||||
{
|
||||
label: tx`Run '${config.name}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "run",
|
||||
shortcut: shortcutLabel("run.runContext"),
|
||||
run: () =>
|
||||
@@ -92,7 +91,6 @@ async function profileMenu(entry: ScriptEntry, path: string): Promise<MenuItem[]
|
||||
},
|
||||
{
|
||||
label: tx`Debug '${config.name}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "debug",
|
||||
shortcut: shortcutLabel("run.debugContext"),
|
||||
run: () => void executeAction("run.debugConfig", config),
|
||||
|
||||
@@ -283,7 +283,6 @@ export async function scriptMenuItems(entry: ScriptEntry, path: string, content:
|
||||
return [
|
||||
{
|
||||
label: tx`Run '${label}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "run",
|
||||
shortcut: shortcutLabel("run.runContext"),
|
||||
run: () =>
|
||||
@@ -293,7 +292,6 @@ export async function scriptMenuItems(entry: ScriptEntry, path: string, content:
|
||||
},
|
||||
{
|
||||
label: tx`Debug '${label}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "debug",
|
||||
shortcut: shortcutLabel("run.debugContext"),
|
||||
run: () => void executeAction("run.debugConfig", config),
|
||||
|
||||
@@ -109,18 +109,11 @@ export function targetMenuItems(target: RunTarget, path: string, content: string
|
||||
: { run: () => void launch(target, path, debug, content) };
|
||||
const debuggable = !p || canDebugProduced(p);
|
||||
return [
|
||||
{
|
||||
label: tx`Run '${name}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "run",
|
||||
shortcut: shortcutLabel("run.runContext"),
|
||||
...pick(false),
|
||||
} as MenuItem,
|
||||
{ label: tx`Run '${name}'`, icon: "run", shortcut: shortcutLabel("run.runContext"), ...pick(false) } as MenuItem,
|
||||
...(debuggable
|
||||
? [
|
||||
{
|
||||
label: tx`Debug '${name}'`,
|
||||
preserveLabelEnd: true,
|
||||
icon: "debug",
|
||||
shortcut: shortcutLabel("run.debugContext"),
|
||||
...pick(true),
|
||||
|
||||
@@ -103,9 +103,9 @@ describe("replace flow model", () => {
|
||||
});
|
||||
|
||||
it("confirmation and summary texts carry the counts", () => {
|
||||
expect(confirmText({ usages: 1, files: 1 })).toBe("Replace 1 occurrence in 1 file?");
|
||||
expect(confirmText({ usages: 3, files: 1 })).toBe("Replace 3 occurrences in 1 file?");
|
||||
expect(confirmText({ usages: 3, files: 2 })).toBe("Replace 3 occurrences in 2 files?");
|
||||
expect(confirmText({ usages: 3, files: 1 }, "foo", "bar")).toBe(
|
||||
"Replace 3 occurrences of 'foo' with 'bar' in 1 file?",
|
||||
);
|
||||
expect(summaryText({ files: 2, replacements: 1, failed: 0, cancelled: false, elapsedMs: 3 })).toBe(
|
||||
"Replaced 1 occurrence in 2 files",
|
||||
);
|
||||
|
||||
@@ -248,20 +248,6 @@
|
||||
.rightActive {
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.textLocation {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.textFile {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.textLine {
|
||||
flex: none;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.actionRow {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
@@ -934,11 +934,8 @@ function ResultRow({
|
||||
<span className={styles.main}>
|
||||
<CodeText path={row.path} text={row.text} indices={row.indices} />
|
||||
</span>
|
||||
<span className={clsx(styles.right, styles.textLocation, active && styles.rightActive)}>
|
||||
<span className={clsx(styles.textFile, repeat && !active && styles.repeat)} title={row.rel}>
|
||||
{basename(row.rel)}
|
||||
</span>{" "}
|
||||
<span className={styles.textLine}>{row.line + 1}</span>
|
||||
<span className={clsx(styles.right, active && styles.rightActive)}>
|
||||
<span className={clsx(repeat && !active && styles.repeat)}>{basename(row.rel)}</span> {row.line + 1}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -201,32 +201,23 @@
|
||||
.previewHeader {
|
||||
flex: none;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: var(--space-1);
|
||||
padding: 10px 20px var(--space-1-5);
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
height: 36px;
|
||||
padding: 0 20px;
|
||||
border-top: 1px solid var(--border-popup);
|
||||
color: var(--fg-subtle);
|
||||
font-size: var(--fs-ui);
|
||||
line-height: 1.25;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.previewDirectory {
|
||||
display: flex;
|
||||
.previewPath {
|
||||
min-width: 0;
|
||||
}
|
||||
.previewName,
|
||||
.previewSegment {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.previewName,
|
||||
.previewParent {
|
||||
flex: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.previewName {
|
||||
color: var(--fg-strong);
|
||||
margin-right: 8px;
|
||||
}
|
||||
.previewBox {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { SearchHistoryMenu } from "@/ui/SearchHistoryMenu";
|
||||
import {
|
||||
useEffect,
|
||||
useId,
|
||||
@@ -40,12 +39,14 @@ import {
|
||||
} from "@/ui";
|
||||
import { useRowHeight } from "@/ui/density";
|
||||
import { maybeEditorService, notifications } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { basename, dirname, openLocation } from "../common/open";
|
||||
import { CodePreview, MatchText, ReplaceDiffPreview } from "./parts";
|
||||
import { clearPreviewCache } from "./preview";
|
||||
import { confirmReplacement } from "./ReplaceAllConfirmation";
|
||||
import {
|
||||
NO_MARKS,
|
||||
confirmAllText,
|
||||
confirmText,
|
||||
countUsages,
|
||||
groupState,
|
||||
loadReplacePreview,
|
||||
@@ -73,6 +74,7 @@ import {
|
||||
customScopeName,
|
||||
customScopeValue,
|
||||
describeQuery,
|
||||
findHistory,
|
||||
hideFindPopup,
|
||||
recentMasks,
|
||||
rememberFindString,
|
||||
@@ -282,8 +284,6 @@ function FindInFilesDialog() {
|
||||
const rows = useMemo(() => matchRows(state.files), [state.files]);
|
||||
const active = rows.length ? Math.min(sel.lead, rows.length - 1) : -1;
|
||||
const selected = active >= 0 ? rows[active] : undefined;
|
||||
const previewDirectory = selected?.relPath.includes("/") ? dirname(selected.relPath) : "";
|
||||
const previewParentStart = Math.max(0, previewDirectory.lastIndexOf("/"));
|
||||
const chosen = useMemo(() => selectedRows(rows, sel), [rows, sel]);
|
||||
const fileHighlights = useMemo(() => {
|
||||
if (stale || !selected) return [];
|
||||
@@ -346,11 +346,22 @@ function FindInFilesDialog() {
|
||||
void replaceAll(usages);
|
||||
return;
|
||||
}
|
||||
const ok = await confirmReplacement({
|
||||
counts: allInScope ? null : counts,
|
||||
pattern: s.pattern,
|
||||
replacement: s.replacement || "",
|
||||
hasExclusions: marks.excluded.size > 0,
|
||||
const ok = await confirm({
|
||||
title: "Replace All",
|
||||
ok: "Replace",
|
||||
message: (
|
||||
<>
|
||||
{allInScope
|
||||
? confirmAllText(s.pattern, s.replacement || "")
|
||||
: confirmText(counts, s.pattern, s.replacement || "")}
|
||||
{marks.excluded.size > 0 && (
|
||||
<>
|
||||
{" "}
|
||||
<T>Excluded usages are skipped.</T>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
});
|
||||
if (ok) void replaceAll(usages, allInScope);
|
||||
};
|
||||
@@ -552,6 +563,19 @@ function FindInFilesDialog() {
|
||||
checked: m === s.mask ? true : undefined,
|
||||
run: () => set({ mask: m, maskEnabled: true }),
|
||||
}));
|
||||
const historyItems = (kind: "find" | "replace"): MenuItem[] => {
|
||||
const h = findHistory(kind);
|
||||
return h.length
|
||||
? [
|
||||
{ kind: "header", label: kind === "find" ? "Recent Searches" : "Recent Replacements" },
|
||||
...h.map((q) => ({
|
||||
label: q,
|
||||
verbatim: true,
|
||||
run: () => set(kind === "find" ? { pattern: q } : { replacement: q }),
|
||||
})),
|
||||
]
|
||||
: [{ label: kind === "find" ? "No recent searches" : "No recent replacements", disabled: true }];
|
||||
};
|
||||
const contextItems: MenuItem[] = SEARCH_CONTEXTS.map((c) => ({
|
||||
label: c.label,
|
||||
checked: c.value === s.context ? true : undefined,
|
||||
@@ -866,21 +890,16 @@ function FindInFilesDialog() {
|
||||
</SplitPanel>
|
||||
<SplitHandle hairline={false} />
|
||||
<SplitPanel id="preview" minSize={96}>
|
||||
{selected && (
|
||||
<div className={styles.previewHeader} title={selected.relPath}>
|
||||
<span className={styles.previewName}>{basename(selected.relPath)}</span>
|
||||
{previewDirectory && (
|
||||
<span className={styles.previewDirectory} dir="ltr">
|
||||
{previewParentStart > 0 && (
|
||||
<span className={styles.previewSegment}>{previewDirectory.slice(0, previewParentStart)}</span>
|
||||
)}
|
||||
<span className={clsx(styles.previewSegment, styles.previewParent)}>
|
||||
{previewDirectory.slice(previewParentStart)}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.previewHeader}>
|
||||
{selected ? (
|
||||
<span className={styles.previewPath}>
|
||||
<span className={styles.previewName}>{basename(selected.relPath)}</span>
|
||||
{selected.relPath.includes("/") && dirname(selected.relPath)}
|
||||
</span>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.previewBox}>
|
||||
{!stale && previewMode && s.replace && selected ? (
|
||||
<ReplaceDiffPreview
|
||||
@@ -955,10 +974,12 @@ function FindInFilesDialog() {
|
||||
placement="bottom-end"
|
||||
onClose={() => setMaskMenu(false)}
|
||||
/>
|
||||
<SearchHistoryMenu
|
||||
kind={historyMenu}
|
||||
<Menu
|
||||
open={historyMenu !== null}
|
||||
anchor={historyMenu === "replace" ? replaceBoxRef : patternBoxRef}
|
||||
onSelect={(value) => set(historyMenu === "replace" ? { replacement: value } : { pattern: value })}
|
||||
items={historyMenu ? historyItems(historyMenu) : []}
|
||||
placement="bottom-start"
|
||||
aria-label="Recent searches"
|
||||
onClose={() => setHistoryMenu(null)}
|
||||
/>
|
||||
<Menu
|
||||
|
||||
@@ -23,12 +23,14 @@ import {
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { notifications, useOccurrenceNavigator } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { basename, openLocation, relDir } from "../common/open";
|
||||
import { countFileMatches } from "./session";
|
||||
import { CodePreview, MatchText, type PreviewHighlight } from "./parts";
|
||||
import { confirmReplacement } from "./ReplaceAllConfirmation";
|
||||
import {
|
||||
NO_MARKS,
|
||||
confirmAllText,
|
||||
confirmText,
|
||||
countUsages,
|
||||
groupState,
|
||||
loadReplacePreview,
|
||||
@@ -367,11 +369,22 @@ function FindTabView({ tab }: { tab: FindTab }) {
|
||||
// Past the search's limit, every match in the scope is replaced, listed or not (as in IDEA).
|
||||
const allInScope = !!st.summary?.limitHit;
|
||||
const confirmReplaceAll = async () => {
|
||||
const ok = await confirmReplacement({
|
||||
counts: allInScope ? null : countUsages(allPending),
|
||||
pattern: tab.query.pattern,
|
||||
replacement: tab.replacement ?? "",
|
||||
hasExclusions: marks.excluded.size > 0,
|
||||
const ok = await confirm({
|
||||
title: "Replace All",
|
||||
ok: "Replace",
|
||||
message: (
|
||||
<>
|
||||
{allInScope
|
||||
? confirmAllText(tab.query.pattern, tab.replacement ?? "")
|
||||
: confirmText(countUsages(allPending), tab.query.pattern, tab.replacement ?? "")}
|
||||
{marks.excluded.size > 0 && (
|
||||
<>
|
||||
{" "}
|
||||
<T>Excluded usages are skipped.</T>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
),
|
||||
});
|
||||
if (ok) void replace(allPending, allInScope);
|
||||
};
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
.content {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
|
||||
.content p,
|
||||
.values,
|
||||
.values dd,
|
||||
.values pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.values {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-items: start;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.values dt {
|
||||
padding-block: var(--space-1);
|
||||
color: var(--fg-secondary);
|
||||
}
|
||||
|
||||
.values pre {
|
||||
max-height: 5em;
|
||||
padding: var(--space-1) var(--space-2);
|
||||
overflow: auto;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-field);
|
||||
font-family: var(--font-mono);
|
||||
font-size: inherit;
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.values pre:focus-visible {
|
||||
outline: 1px solid var(--focus-ring);
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: var(--fg-muted);
|
||||
font-family: var(--font-ui);
|
||||
}
|
||||
|
||||
.note {
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { T } from "@/ui";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { confirmText, type ReplaceCounts } from "./replaceFlow";
|
||||
import styles from "./ReplaceAllConfirmation.module.css";
|
||||
|
||||
export function confirmReplacement({
|
||||
counts,
|
||||
pattern,
|
||||
replacement,
|
||||
hasExclusions,
|
||||
}: {
|
||||
counts: ReplaceCounts | null;
|
||||
pattern: string;
|
||||
replacement: string;
|
||||
hasExclusions: boolean;
|
||||
}): Promise<boolean> {
|
||||
return confirm({
|
||||
title: "Replace All",
|
||||
ok: "Replace",
|
||||
message: (
|
||||
<div className={styles.content}>
|
||||
<p>{counts ? confirmText(counts) : <T>Replace every occurrence in the scope?</T>}</p>
|
||||
<dl className={styles.values}>
|
||||
<dt>
|
||||
<T>Text to find</T>
|
||||
</dt>
|
||||
<dd>
|
||||
<pre role="region" aria-label={tx("Text to find")} tabIndex={0}>
|
||||
{pattern}
|
||||
</pre>
|
||||
</dd>
|
||||
<dt>
|
||||
<T>Replace with</T>
|
||||
</dt>
|
||||
<dd>
|
||||
<pre role="region" aria-label={tx("Replace with")} tabIndex={0}>
|
||||
{replacement || (
|
||||
<span className={styles.empty}>
|
||||
<T>Empty text</T>
|
||||
</span>
|
||||
)}
|
||||
</pre>
|
||||
</dd>
|
||||
</dl>
|
||||
{!counts && (
|
||||
<p className={styles.note}>
|
||||
<T>The search hit its limit, so it runs again to find any additional matches.</T>
|
||||
</p>
|
||||
)}
|
||||
{hasExclusions && (
|
||||
<p className={styles.note}>
|
||||
<T>Excluded usages are skipped.</T>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -1,32 +1,26 @@
|
||||
.body {
|
||||
display: grid;
|
||||
grid-template-columns: 200px minmax(0, 1fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
height: clamp(240px, 55vh, 360px);
|
||||
grid-template-columns: 200px 1fr;
|
||||
min-height: 300px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-small);
|
||||
overflow: hidden;
|
||||
}
|
||||
.side {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
border-inline-end: 1px solid var(--border);
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
.toolbar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
gap: var(--space-0-5);
|
||||
padding: var(--space-1);
|
||||
padding: 4px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
padding: var(--space-1);
|
||||
scroll-padding-block: var(--space-1);
|
||||
padding: 4px;
|
||||
list-style: none;
|
||||
overflow: auto;
|
||||
}
|
||||
@@ -35,16 +29,13 @@
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: var(--h-list-row);
|
||||
padding: 0 var(--space-2);
|
||||
padding: 0 8px;
|
||||
border: 0;
|
||||
border-radius: var(--radius-row);
|
||||
background: none;
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
text-align: start;
|
||||
}
|
||||
.item > span {
|
||||
min-width: 0;
|
||||
text-align: left;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -56,25 +47,16 @@
|
||||
background: var(--bg-list-selected);
|
||||
}
|
||||
.empty {
|
||||
padding: var(--space-2);
|
||||
padding: 8px;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.form {
|
||||
display: grid;
|
||||
grid-template-columns: max-content minmax(0, 1fr);
|
||||
align-items: center;
|
||||
align-content: start;
|
||||
gap: var(--space-2) var(--space-3);
|
||||
padding: var(--space-3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1-5);
|
||||
padding: 10px 14px;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
.form > .error,
|
||||
.form > .empty,
|
||||
.help {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
.label {
|
||||
color: var(--fg-muted);
|
||||
@@ -83,11 +65,10 @@
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-size: var(--fs-small);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.help {
|
||||
margin: 0;
|
||||
padding-inline-start: var(--space-4);
|
||||
margin: 6px 0 0;
|
||||
padding-left: 16px;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
line-height: 1.6;
|
||||
@@ -96,15 +77,3 @@
|
||||
font-family: var(--font-mono);
|
||||
color: var(--fg);
|
||||
}
|
||||
|
||||
@media (max-width: 540px) {
|
||||
.body {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
grid-template-rows: minmax(84px, 1fr) minmax(0, auto);
|
||||
height: clamp(240px, 65vh, 360px);
|
||||
}
|
||||
.side {
|
||||
border-inline-end: 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
Loaded 100 of 156 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user