mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 23:56:05 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d35a5e7d9 | ||
|
|
844c2f3145 |
No files matched your search
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
|
||||
assert_eq!(b.pom, canonical);
|
||||
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
|
||||
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
|
||||
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
|
||||
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
|
||||
|
||||
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
|
||||
assert_eq!(
|
||||
@@ -63,13 +63,26 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
|
||||
let gone = ops::build::build_model(&host, "main").await.unwrap();
|
||||
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
|
||||
assert!(host.project("main").unwrap().content_roots().is_empty());
|
||||
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
|
||||
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
|
||||
assert_eq!(saved(), Vec::<String>::new());
|
||||
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
|
||||
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
|
||||
host.shutdown().await;
|
||||
}
|
||||
|
||||
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
|
||||
/// the background.
|
||||
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
|
||||
for _ in 0..200 {
|
||||
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
|
||||
if ready(&roots) {
|
||||
return roots;
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
|
||||
}
|
||||
host.project("main").unwrap().lsp.jdtls_import_roots()
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function show(page: Page, action: string) {
|
||||
await page.evaluate(async (action) => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
if (!(await (await import(/* @vite-ignore */ actions)).executeAction(action))) throw Error(action);
|
||||
}, action);
|
||||
}
|
||||
|
||||
test("analysis scope fields align with their radio choices and retain their values", async ({ workbench: page }) => {
|
||||
await page.evaluate(async () => {
|
||||
const search = "/src/platform/search.ts";
|
||||
(await import(/* @vite-ignore */ search)).saveCustomScopes([
|
||||
{ name: "Frontend", pattern: "file:src//*" },
|
||||
{ name: "Tests", pattern: "file:tests//*" },
|
||||
]);
|
||||
});
|
||||
await show(page, "analyze.inspectCode");
|
||||
const dialog = page.getByRole("dialog", { name: "Specify Inspection Scope" });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
const custom = scope.getByRole("button", { name: "Custom scope", exact: true });
|
||||
const radio = scope.getByRole("radio", { name: "Module or directory" });
|
||||
const label = scope.getByText("Module or directory", { exact: true });
|
||||
|
||||
await radio.check();
|
||||
const path = (await directory.boundingBox())!;
|
||||
const choice = (await label.boundingBox())!;
|
||||
expect(path.y + path.height / 2).toBeCloseTo(choice.y + choice.height / 2, 0);
|
||||
await directory.fill("/dev/acme-api/src");
|
||||
await expect(custom).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(directory).toBeDisabled();
|
||||
expect((await custom.boundingBox())!.x).toBeCloseTo(path.x, 0);
|
||||
await custom.click();
|
||||
await page.getByRole("option", { name: /^Tests/ }).click();
|
||||
await expect(custom).toContainText("Tests");
|
||||
|
||||
await radio.check();
|
||||
await expect(directory).toHaveValue("/dev/acme-api/src");
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(custom).toContainText("Tests");
|
||||
await page.setViewportSize({ width: 400, height: 640 });
|
||||
const stacked = (await directory.boundingBox())!;
|
||||
const customBox = (await custom.boundingBox())!;
|
||||
const radioBox = (await label.boundingBox())!;
|
||||
const next = (await scope.getByText("Current file", { exact: true }).boundingBox())!;
|
||||
expect(stacked.y).toBeGreaterThan(radioBox.y + radioBox.height);
|
||||
expect(stacked.y + stacked.height).toBeLessThan(next.y);
|
||||
expect(stacked.x).toBeCloseTo(customBox.x, 0);
|
||||
expect(await scope.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
for (const [action, title] of [
|
||||
["code.cleanup", "Run Code Cleanup"],
|
||||
["analyze.locateDuplicates", "Locate Duplicates"],
|
||||
["find.structural", "Structural Search"],
|
||||
["find.replaceStructural", "Structural Replace"],
|
||||
] as const) {
|
||||
test(`${title} keeps directory options with their scope choice`, async ({ workbench: page }) => {
|
||||
await show(page, action);
|
||||
const dialog = page.getByRole("dialog", { name: title });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
await expect(directory).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Module or directory" }).check();
|
||||
await expect(directory).toBeEnabled();
|
||||
await expect(scope.getByRole("button", { name: "Browse…" })).toBeEnabled();
|
||||
});
|
||||
}
|
||||
@@ -85,66 +85,6 @@ test("⌘K commits the checked changes with the typed message", async ({ workben
|
||||
await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden();
|
||||
});
|
||||
|
||||
test("commit options align author fields and keep the date editable in a narrow dialog", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await stubRepository(page);
|
||||
await page.setViewportSize({ width: 1040, height: 700 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
const panel = page.getByRole("region", { name: "Commit", exact: true });
|
||||
await panel.getByRole("button", { name: "Commit Options", exact: true }).click();
|
||||
const popup = page.getByRole("dialog", { name: "Commit Options", exact: true });
|
||||
const author = popup.getByRole("textbox", { name: "Author", exact: true });
|
||||
const date = popup.getByLabel("Author date", { exact: true });
|
||||
const clear = popup.getByRole("button", { name: "Clear author date", exact: true });
|
||||
const name = "Regional Ledger Review <[email protected]>";
|
||||
const time = "2024-06-04T13:20:21";
|
||||
await author.fill(name);
|
||||
await date.fill(time);
|
||||
const authorBox = (await author.boundingBox())!;
|
||||
const dateBox = (await date.boundingBox())!;
|
||||
const dateLabel = (await popup.getByText("Author date", { exact: true }).boundingBox())!;
|
||||
const clearBox = (await clear.boundingBox())!;
|
||||
expect(authorBox.x).toBeCloseTo(dateBox.x, 0);
|
||||
expect(dateLabel.y).toBeGreaterThanOrEqual(dateBox.y);
|
||||
expect(dateLabel.y).toBeLessThan(dateBox.y + dateBox.height);
|
||||
expect(clearBox.x + clearBox.width).toBeCloseTo(authorBox.x + authorBox.width, 0);
|
||||
await expect(clear).toBeInViewport({ ratio: 1 });
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(popup).toBeHidden();
|
||||
await page.evaluate(async () => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, vcs: { ...settings?.vcs, commit: { ...settings?.vcs?.commit, nonModal: false } } },
|
||||
});
|
||||
});
|
||||
await page.setViewportSize({ width: 650, height: 650 });
|
||||
await page.keyboard.press("Meta+k");
|
||||
const dialog = page.getByRole("dialog", { name: "Commit Changes", exact: true });
|
||||
const options = dialog.getByRole("group", { name: "Commit Options", exact: true });
|
||||
const compactAuthor = options.getByRole("textbox", { name: "Author", exact: true });
|
||||
const compactDate = options.getByLabel("Author date", { exact: true });
|
||||
const compactClear = options.getByRole("button", { name: "Clear author date", exact: true });
|
||||
await expect(compactAuthor).toHaveValue(name);
|
||||
await expect(compactDate).toHaveValue(time);
|
||||
const labelBox = (await options.getByText("Author:", { exact: true }).boundingBox())!;
|
||||
const inputBox = (await compactAuthor.boundingBox())!;
|
||||
expect(inputBox.x).toBeCloseTo(labelBox.x, 0);
|
||||
expect(inputBox.y).toBeGreaterThanOrEqual(labelBox.y + labelBox.height);
|
||||
const box = (await compactDate.boundingBox())!;
|
||||
const buttonBox = (await compactClear.boundingBox())!;
|
||||
expect(box.width).toBeCloseTo(inputBox.width, 0);
|
||||
expect(buttonBox.y).toBeGreaterThanOrEqual(box.y + box.height);
|
||||
expect(await options.evaluate((node) => node.scrollWidth - node.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await compactClear.click();
|
||||
await expect(compactDate).toHaveValue("");
|
||||
await expect(compactClear).toBeHidden();
|
||||
await expect(compactAuthor).toHaveValue(name);
|
||||
});
|
||||
|
||||
test("the Commit window gives its message preferred focus", async ({ workbench: page }) => {
|
||||
await stubRepository(page);
|
||||
const stripe = page.locator('[data-stripe-button="commit"]');
|
||||
|
||||
@@ -161,34 +161,51 @@
|
||||
padding: 14px;
|
||||
}
|
||||
.scope {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-0-5);
|
||||
container: analysis-scope / inline-size;
|
||||
min-inline-size: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.scopeOptions {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(45%) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
}
|
||||
.fieldLabel {
|
||||
padding: 0 0 4px;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.radioRow {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
padding-block: var(--space-0-5);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.scopeWithField {
|
||||
grid-column: 1;
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: 3px 0;
|
||||
color: var(--fg);
|
||||
cursor: default;
|
||||
}
|
||||
.radioRow input {
|
||||
margin: 0;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
.dirRow {
|
||||
display: flex;
|
||||
gap: var(--space-1-5);
|
||||
padding: 4px 0 0 22px;
|
||||
min-width: 0;
|
||||
}
|
||||
.scopeControl > button:last-child {
|
||||
flex: none;
|
||||
}
|
||||
@container analysis-scope (max-width: 336px) {
|
||||
.scopeOptions {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 1;
|
||||
padding-inline-start: calc(16px + var(--space-2));
|
||||
margin-block-end: var(--space-1);
|
||||
}
|
||||
}
|
||||
.grow {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/** Dialog stack of the analysis feature and the shared "Specify Scope" fields. */
|
||||
import { Fragment, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { create } from "zustand";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { isTauri } from "@/platform/ipc";
|
||||
import { EDIT_SCOPES_ACTION, useCustomScopeList } from "@/platform/search";
|
||||
import { Button, IconButton, Input, Select, T } from "@/ui";
|
||||
import { Button, IconButton, Input, Radio, Select, T } from "@/ui";
|
||||
import { SCOPE_LABELS, currentFile, type ScopeChoice, type ScopeKind } from "./scope";
|
||||
import styles from "./Analysis.module.css";
|
||||
|
||||
@@ -62,57 +63,69 @@ export function ScopeFields({
|
||||
}) {
|
||||
const file = currentFile();
|
||||
const scopes = useCustomScopeList();
|
||||
const custom = value.custom ?? scopes[0]?.name;
|
||||
return (
|
||||
<fieldset className={styles.scope}>
|
||||
<legend className={styles.fieldLabel}>
|
||||
<T>Scope</T>
|
||||
</legend>
|
||||
{kinds.map((kind) => (
|
||||
<label key={kind} className={styles.radioRow}>
|
||||
<input
|
||||
type="radio"
|
||||
name={name}
|
||||
checked={value.kind === kind}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() =>
|
||||
onChange({ ...value, kind, custom: kind === "custom" ? (value.custom ?? scopes[0]?.name) : value.custom })
|
||||
}
|
||||
/>
|
||||
<span>{kind === "file" && file ? tx`File '${file.split("/").pop()}'` : tx(SCOPE_LABELS[kind])}</span>
|
||||
</label>
|
||||
))}
|
||||
{value.kind === "directory" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{value.kind === "custom" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={value.custom ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder="No custom scopes"
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, value.custom ? { select: value.custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.scopeOptions}>
|
||||
{kinds.map((kind) => {
|
||||
const selected = value.kind === kind;
|
||||
return (
|
||||
<Fragment key={kind}>
|
||||
<Radio
|
||||
name={name}
|
||||
checked={selected}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() => onChange({ ...value, kind, custom: kind === "custom" ? custom : value.custom })}
|
||||
label={
|
||||
kind === "file" && file ? <span>{tx`File '${file.split("/").pop()}'`}</span> : SCOPE_LABELS[kind]
|
||||
}
|
||||
className={clsx(styles.radioRow, (kind === "directory" || kind === "custom") && styles.scopeWithField)}
|
||||
/>
|
||||
{kind === "directory" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
disabled={!selected}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
disabled={!selected}
|
||||
onClick={() =>
|
||||
void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))
|
||||
}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{kind === "custom" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={(selected ? value.custom : custom) ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder={scopes.length ? "Choose a scope" : "No custom scopes"}
|
||||
disabled={!selected}
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
disabled={!selected}
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, custom ? { select: custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -33,17 +33,15 @@ export function CommitAuthorFields({
|
||||
focusAuthor?: boolean;
|
||||
onChange: (update: Partial<CommitAuthor>) => void;
|
||||
}) {
|
||||
const authorId = useId();
|
||||
const authorDateId = useId();
|
||||
const date = authorDate ? new Date(authorDate) : null;
|
||||
return (
|
||||
<div className={styles.optIdentity}>
|
||||
<div className={styles.optIdentityFields}>
|
||||
<label htmlFor={authorId}>
|
||||
<>
|
||||
<label className={styles.optField}>
|
||||
<span>
|
||||
<T>Author:</T>
|
||||
</label>
|
||||
</span>
|
||||
<Input
|
||||
id={authorId}
|
||||
value={author}
|
||||
title={tx(
|
||||
preserveOriginal
|
||||
@@ -55,6 +53,8 @@ export function CommitAuthorFields({
|
||||
autoSelect={focusAuthor}
|
||||
onChange={(e) => onChange({ author: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
<div className={styles.optDate}>
|
||||
<label htmlFor={authorDateId}>
|
||||
<T>Author date</T>
|
||||
</label>
|
||||
@@ -81,6 +81,6 @@ export function CommitAuthorFields({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -309,7 +309,7 @@
|
||||
}
|
||||
/* Commit Options popup (gear next to Commit). */
|
||||
.options {
|
||||
width: 384px;
|
||||
width: 340px;
|
||||
max-height: min(560px, 80vh);
|
||||
overflow: auto;
|
||||
padding: 4px 16px 12px;
|
||||
@@ -350,35 +350,29 @@
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.optIdentity {
|
||||
container-type: inline-size;
|
||||
}
|
||||
.optIdentityFields {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
.optField {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1) var(--space-2);
|
||||
gap: var(--space-2);
|
||||
color: var(--fg);
|
||||
font-size: var(--fs-ui);
|
||||
}
|
||||
.optIdentityFields > label {
|
||||
overflow-wrap: anywhere;
|
||||
.optField > :last-child {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
@container (min-width: 328px) {
|
||||
.optIdentityFields {
|
||||
grid-template-columns: fit-content(32%) minmax(0, 1fr);
|
||||
row-gap: var(--space-1-5);
|
||||
}
|
||||
.optDate {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
color: var(--fg);
|
||||
}
|
||||
.optDateInput {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: var(--space-1);
|
||||
}
|
||||
.optDateInput input {
|
||||
flex: 1 1 min(100%, 212px);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.optLink {
|
||||
|
||||
Reference in new issue
Block a user