Compare commits

..
Author SHA1 Message Date
l0ng-ai 9415584b54 fix(debugger): align the Python table viewer 2026-11-23 11:01:18 +08:00
l0ng-ai 7e5a2cf051 fix(vcs): group Git Log display settings (#5287)
Settings → Version Control → Log now groups the display and column checkboxes under titled separators. Both groups use the same checkbox alignment, row spacing, and UI font size, so the controls are easier to scan at narrow window widths.
2026-11-23 10:32:53 +08:00
l0ng-ai c4e08a9676 fix(gradle): keep task descriptions in row tooltips (#5286)
Gradle task rows give the available space beside the icon to the task name. The full description appears in the row tooltip, where assistive technology can also read it.
2026-11-23 10:06:57 +08:00
l0ng-ai 2c0b76c9e6 fix(editor): align the line separator menu (#5284)
- Give the line separator picker a standard menu heading. List Windows, Unix and macOS, and classic Mac OS from top to bottom.
- Use the localized platform names and escaped newline sequences in the menu. The status bar still shows the abbreviation and the menu checks the current format.
2026-11-23 09:48:46 +08:00
l0ng-ai 4d1f51c607 fix(editor): integrate usage access filters into the toolbars (#5283)
- Put read and write filters alongside the other actions in Show Usages and in the Find Usages tool window. Both results areas use the space previously occupied by a separate filter row.
- Keep the two buttons together as the popup narrows. The side toolbar can scroll when the tool window is short.
2026-11-23 09:26:05 +08:00
l0ng-ai 2215239ecb fix(editor): put the pin in the editor tab action slot (#5282)
- Put the pin in a pinned editor tab's action slot so the filename has more room. The pin follows the left or right placement and can unpin the tab directly.
- Use the same Unpin action in Hidden Editor Tabs. A modified pinned tab shows its unsaved marker beside the pin.
2026-11-23 09:23:25 +08:00
l0ng-ai 43eeb080be fix(run): expand multiline configuration fields in place (#5267)
Multiline run configuration fields now keep the Expand button inside the field. The larger editor opens next to the field so the configuration stays in view. It can be resized, scrolls long arguments horizontally, and applies edits through OK or Ctrl/⌘+Enter.
2026-11-23 09:16:39 +08:00
l0ng-ai 03a19d4284 fix(search): keep line numbers visible in text results (#5281)
- Give Search Everywhere's Text results a separate column for the line number. Long filenames truncate within the existing metadata width, leaving the same amount of space for the highlighted code snippet.
- Use tabular digits at the trailing edge and show the full relative path on hover.
2026-11-23 09:16:00 +08:00
l0ng-ai 3aeee3fcfc fix(settings): align the navigation tree spacing (#5280)
- Move the top-level disclosure arrows away from the sidebar edge and reduce each nested level from 20 px to 16 px.
- Keep leaf and expandable labels aligned at the same depth. The third-level result has 4 px more room in the 160 px sidebar shown below.
2026-11-23 09:15:52 +08:00
l0ng-ai 471003a8c5 fix(vcs): size annotation details to their content (#5279)
Git annotation details size themselves to the commit text, so short messages cover less of the editor. Long author details and messages wrap within the available width. The revision and its metadata share the tooltip's UI font, and the full revision remains clickable.
2026-11-23 09:15:44 +08:00
l0ng-ai c109773d2a fix(editor): keep completion controls on one row (#5278)
The completion footer keeps its shortcut hint and sorting control on one line. In narrow editor splits the hint shortens first, and hovering reveals its full text. The compact footer takes up less vertical space in the editor.
2026-11-23 09:15:36 +08:00
l0ng-ai ed6b67faed fix(run): keep configuration types reachable in short windows (#5277)
Add New Configuration keeps the title and search field above a scrollable list. The picker keeps its width while filtering with the standard 16 px icons and shows more types when the window has room. After filtering, Enter opens the configuration type highlighted in the list, including types under a group heading.
2026-11-23 09:15:28 +08:00
l0ng-ai ff7bfcaf1d fix(search): keep file context visible in Find previews (#5275)
The source preview in Find in Files and Replace in Files keeps the filename prominent and leaves the end of its containing path visible. The middle of a long directory shortens to fit, and hovering over the caption reveals the full project-relative path.
2026-11-23 09:15:20 +08:00
l0ng-ai 91330a82d0 fix(build): keep diagnostic names and elapsed time readable (#5274)
The Build tree shortens long directory hints first so there is room for the filename and diagnostic counts. The build duration uses smaller, tabular text at the trailing edge. Hovering over a file row reveals its full path.
2026-11-23 09:15:11 +08:00
l0ng-ai ce75c58a34 fix(workbench): give notification balloons room for their content (#5270)
Notification balloons reserve space for Dismiss in the title row. The body and action rows extend underneath it, giving paths and action labels more room to wrap in narrow windows. The cards use the standard UI text size and spacing.
2026-11-23 09:15:01 +08:00
l0ng-ai 03b9070b9b fix(vcs): show file names in staging diff headings (#5268)
The three-way staging diff displays the filename in the index heading. When a version has a different path, its heading shows that filename too. The headings use the standard workbench text size, and hovering over a filename heading reveals its full path.
2026-11-23 09:14:53 +08:00
l0ng-ai f6f610516c fix(vcs): clarify staging groups and row actions (#5266)
The Commit staging tree gives group headings more weight so the staged, unstaged, and unversioned sections are easy to scan. The inline Stage or Unstage action appears on the current selected row and on hover, so a multi-selection shows which row the inline action applies to.
2026-11-23 09:14:44 +08:00
l0ng-ai cf49a91b66 fix(vcs): group branches and tags in commit details (#5265)
Git Log commit details now show branches and tags in separate groups. Reference names use the same size as the surrounding metadata, and each group wraps within the details pane.
2026-11-23 09:14:35 +08:00
l0ng-ai e0a97e32f7 fix(terminal): give scrollback search a compact layout (#5264)
Size the floating terminal find bar to its controls. Keep the match count beside the previous and next buttons, and move the controls below the query in narrow docks so the full first row is available for typing.
2026-11-23 09:14:26 +08:00
l0ng-ai dd0eeeae29 fix(debugger): align compact editor value hints (#5262)
Use the standard bold UI font for compact debugger value hints. Put the variable icon and expand control beside the summary so wrapped values align with their first line. Size the hint to the available editor width, including when a dock reduces the space or the window is resized.
2026-11-23 09:14:18 +08:00
l0ng-ai 4bb22df1fb fix(run): show before-launch tasks as ordered tags (#5261)
Show before-launch tasks as compact tags numbered in execution order. Tags wrap within the configuration form, and each task has a remove button and a menu for moving it up or down. Shell commands stay editable in place.
2026-11-23 09:14:10 +08:00
l0ng-ai aee087597a fix(vcs): show readable commit message history previews (#5258)
Place commit message history just above the editor and use the same font settings as the draft. Show the beginning of the body in each row so messages with the same subject are distinguishable. Keep seven rows visible when space allows and scroll through the rest.
2026-11-23 09:14:02 +08:00
l0ng-ai 993a321dd0 fix(vcs): keep commit check actions visible while reading results (#5257)
Give commit check results their own scroll area. The status icon and retry action stay in place, and the results fit the space above the commit buttons. Use the standard 13 px UI type and a 4 px gap between results.
2026-11-23 09:13:53 +08:00
l0ng-ai 381e66aca5 fix(vcs): keep commit subjects readable in the Amend chooser (#5253)
The Amend chooser sizes to its contents within the window, up to about 520 px. Long subjects get more room and the full text on hover. The latest commit row gives its action label more weight and leaves the subject in secondary text. The list still shows five rows before scrolling.
2026-11-23 09:13:45 +08:00
l0ng-ai d7a05eea21 fix(vcs): align commit author and date fields (#5252)
Commit Options gives the author and date fields a shared label column when there is room. A narrow options pane puts the labels above the controls and moves the clear button below the date when needed. In the 650 px desktop window, the author input grew from 104 px to 157 px, and the date input grew from 133 px to 157 px. The native date control can still clip part of the time display at that width.
2026-11-23 09:13:37 +08:00
l0ng-ai c61ddbff3d fix(vcs): make Git Log commit choices easier to scan (#5250)
The Git Log commit chooser now gives its results the full dialog width and sizes the list to the number of candidates. Previously the list could be clipped inside a fixed-height area. Each row separates the subject from the hash, author and timestamp. The search field keeps keyboard focus while the arrow keys move the selection.
2026-11-23 09:13:30 +08:00
l0ng-ai 0c20d72cbf fix(project): group file rename options below the name field (#5247)
Project tree Rename places the name prompt directly above the input and keeps the two search options together below it. The options share one row when they fit and wrap at the dialog width. This gives the name and any validation message a clear place in the form.
2026-11-23 09:13:22 +08:00
l0ng-ai 021f334c0c fix(run): keep configuration names distinct in gutter menus (#5245)
Run and Debug menus keep the end of a long configuration name visible beside the shortcut. When the label runs out of room, the menu truncates the middle so names with the same prefix remain distinguishable. Hovering still shows the full name.
2026-11-23 09:13:13 +08:00
l0ng-ai c61264cdf9 fix(search): keep recent find and replace values readable (#5244)
The editor Find bar and the Find and Replace in Files dialog now share one history menu. The menu can grow up to 200 px wider than its field, within the window, and the text uses the space previously reserved for icons. The heading stays visible as the list scrolls. Multi-line entries show a line-break marker and restore the original text when selected.
2026-11-23 09:13:05 +08:00
l0ng-ai e4d6f50a0b fix(search): make Replace All details easier to review (#5236)
Replace All puts the affected count above separate, scrollable values for the search text and replacement. Both values stay available in full, and an empty replacement is labeled explicitly. The Replace in Files popup and the Find tool window use the same confirmation.
2026-11-23 09:12:56 +08:00
l0ng-ai 0435e0330e fix(search): keep scope names and patterns readable in the editor dialog (#5231)
The Scopes dialog in Find in Files keeps its list scrollable beside the Name and Pattern fields. At narrow widths the editor moves below the list, giving the pattern more room. Long names show an ellipsis and a tooltip, and the selected scope stays visible when a row is added.
2026-11-23 09:12:48 +08:00
l0ng-ai 13b5f9e575 fix(editor): keep image viewer controls and details readable (#5230)
The image viewer groups the image and zoom controls at the start of a compact toolbar. Its dimensions, file size, and zoom appear at the other end in the standard UI text size. In narrow splits the details wrap onto another row, leaving the SVG Open as Text action readable on one line.
2026-11-23 09:12:39 +08:00
l0ng-ai dde4b28abd fix(editor): keep color picker controls in view (#5228)
The editor color picker uses a shorter color field and a tighter control row. Numeric inputs use the UI text size, recent colors wrap with consistent spacing, and the action buttons stay visible when the popup has to scroll.
2026-11-23 09:12:30 +08:00
l0ng-ai 3817724637 fix(vcs): make files and actions easier to scan in local changes review (#5227)
The local changes review shows the filename first and uses smaller, muted text for its parent folder. This keeps filenames visible when directories are long. The warning and change preservation hint sit together above the file list. Force Checkout sits on the left, with Smart Checkout and cancellation on the right.
2026-11-23 09:12:22 +08:00
l0ng-ai 26b5856ce0 feat(workbench): let users move the More Tool Windows button (#5224)
Right-click **More Tool Windows** (`…`) and choose **Move to Right** or **Move to Left**. The workbench previously placed this button on the left unconditionally. It now starts on the left, remembers your choice across restarts, and opens the list toward the editor from either edge.
2026-11-23 09:12:13 +08:00
l0ng-ai 6aeb733f20 fix(run): make test report export paths easier to edit (#5223)
The test results export dialog puts HTML and XML on separate rows and gives the file name and folder separate fields. The file name is selected on open, so it can be replaced without retyping the directory. Pasting a full path and choosing a destination with Browse still work.
2026-11-23 09:12:05 +08:00
l0ng-ai 29fcec6ab8 fix(debugger): keep gutter breakpoint controls in view (#5221)
The gutter breakpoint popup puts the file and line in a fixed header and keeps the action buttons visible while the fields scroll. The popup gives the condition and hit-count fields more room. Long filenames shorten in the header while the line number stays visible. The same popup layout covers method breakpoints and field watchpoints.
2026-11-23 09:11:56 +08:00
l0ng-ai 5d6c76cdda fix(keymap): make shortcut recording and conflicts easier to read (#5220)
The shortcut recorder puts the action name and its category in the dialog body and uses a full-width first field. The optional second stroke stays beside its checkbox. Conflicting actions use two-line rows that keep the action name, category and binding readable in a narrow window.
2026-11-23 09:11:47 +08:00
l0ng-ai 844c2f3145 test(maven): wait for the background refresh of jdtls import roots (#5272)
external_maven_link_persists_reloads_and_unlink_keeps_files failed on the macOS runner: setting languages.java.maven.linkedProjects refreshes the language server's import roots on a blocking task, and the test read them right after build_model returned. It now waits up to 5 s for them to change.
2026-11-23 05:18:24 +08:00
Charlie.Weiandcharli117 76d67145f5 test(smoke): give the language-smoke closure tests a 20s timeout (#5240)
The two Language smoke workflow tests compute the repo-wide import closure and crate tree. On a CI runner running the whole suite they took longer than vitest's default 5 s and failed the Frontend job on main.

Co-authored-by: charli117 <[email protected]>
2026-11-23 01:13:43 +08:00
Charlie.Weiandcharli117 cf4273eeea chore(deps): bump url to 2.5.9 for RUSTSEC-2026-0592 (#5237)
url 2.5.8 overflows the stack in Url::origin() on nested blob: URLs (RUSTSEC-2026-0592), which failed Cargo deny on main. 2.5.9 fixes it; form_urlencoded moves to 1.2.3 with it. The rest of the lockfile stays as on main.

Co-authored-by: charli117 <[email protected]>
2026-11-23 01:13:33 +08:00
131 changed files with 3834 additions and 1166 deletions

No files matched your search

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