Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai 96eea4704d fix(run): show before-launch tasks as ordered tags 2026-11-23 02:59:59 +08:00
9 змінених файлів з 238 додано та 158 видалено

No files matched your search

+2 -15
Переглянути файл
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
assert_eq!(b.pom, canonical);
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
assert_eq!(
@@ -63,26 +63,13 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
let gone = ops::build::build_model(&host, "main").await.unwrap();
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
assert!(host.project("main").unwrap().content_roots().is_empty());
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
assert_eq!(saved(), Vec::<String>::new());
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
host.shutdown().await;
}
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
/// the background.
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
for _ in 0..200 {
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
if ready(&roots) {
return roots;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
}
host.project("main").unwrap().lsp.jdtls_import_roots()
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
let temp = tempfile::tempdir().unwrap();
-32
Переглянути файл
@@ -111,7 +111,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
});
await expect(editor.locator(".cm-content")).toHaveCSS("font-size", zoomedSize);
await expect(method.locator(".cm-completionLabel")).toHaveCSS("font-size", zoomedSize);
await page.keyboard.type("toD");
await expect(popup.getByText("total", { exact: true })).toBeHidden();
// Refreshing the results rebuilds the list; the hint bar must stay below it, not jump to the top.
@@ -125,37 +124,6 @@ test("completion lists the server's items and inserts the chosen one", async ({
await expect(popup).toBeHidden();
await expect(editor.locator(".cm-activeLine")).toHaveText(/^\s*order\.toDto\(\)$/);
expect((await ipcCalls(page, "lsp_completion")).length).toBeGreaterThan(0);
await page.evaluate(async () => {
const path = "/src/platform/actions.ts";
await (await import(/* @vite-ignore */ path)).executeAction("editor.splitRight");
});
const panes = page.locator("[data-pane-id]");
await expect(panes).toHaveCount(2);
await page.setViewportSize({ width: 480, height: 760 });
await panes.last().locator(".cm-content").focus();
await page.keyboard.press("End");
await page.keyboard.press("Enter");
await page.keyboard.type("order.");
await page.keyboard.press("Control+Space");
const footer = popup.locator(".cm-lsp-completion-footer");
await expect
.poll(() =>
footer.evaluate((el) => {
const tip = el.querySelector("span")!;
const sort = el.querySelector("button")!;
const a = tip.getBoundingClientRect();
const b = sort.getBoundingClientRect();
return {
oneRow: Math.abs(a.y + a.height / 2 - b.y - b.height / 2) <= 1,
hintClipped: tip.scrollWidth > tip.clientWidth,
sortFits: sort.scrollWidth <= sort.clientWidth + 1 && b.right <= el.getBoundingClientRect().right,
};
}),
)
.toEqual({ oneRow: true, hintClipped: true, sortFits: true });
await expect(footer.getByTitle("Press ↵ to insert, ⇥ to replace")).toHaveCSS("font-size", "12px");
await expect(footer.getByRole("button", { name: "Sort by name" })).toBeInViewport({ ratio: 1 });
});
test("long completion signatures fit the editor when the workbench is narrowed", async ({ workbench: page }) => {
+73 -30
Переглянути файл
@@ -1,39 +1,82 @@
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) => {
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" }],
},
{ ...base, id: "layout:prepare", name: "Prepare generated sources for the payments development server" },
],
selectedId: "layout:app",
loaded: true,
editorOpen: true,
});
}, target);
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);
-1
Переглянути файл
@@ -1045,7 +1045,6 @@ const completionPopup = ViewPlugin.fromClass(
footer.className = "cm-lsp-completion-footer";
const tip = document.createElement("span");
tip.textContent = tx("Press ↵ to insert, ⇥ to replace");
tip.title = tip.textContent;
footer.append(tip, sortToggle(this.view));
}
// CodeMirror appends a fresh list when the candidates change.
+8 -21
Переглянути файл
@@ -212,28 +212,22 @@ export const lspTheme = EditorView.theme({
color: "var(--fg-muted)",
},
".cm-lsp-completion-footer, .cm-lsp-inplace-footer": {
display: "flex",
flex: "none",
flexWrap: "wrap",
alignItems: "center",
padding: "5px 12px",
backgroundColor: "var(--bg-popup-inline, var(--bg-elev))",
color: "var(--fg-subtle)",
fontFamily: "var(--font-ui)",
fontSize: "var(--fs-small)",
gap: "var(--space-1) var(--space-3)",
justifyContent: "space-between",
borderRadius: "0 0 calc(var(--radius-popup) - 1px) calc(var(--radius-popup) - 1px)",
},
".cm-lsp-completion-footer": {
display: "grid",
gridTemplateColumns: "minmax(0, 1fr) minmax(0, max-content)",
gap: "var(--space-2)",
paddingBlock: "var(--space-1) 3px",
paddingInline: "var(--space-3) var(--space-2)",
},
".cm-lsp-completion-footer > span, .cm-lsp-completion-sort": {
minWidth: "0",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
},
".cm-lsp-completion-sort": {
flex: "none",
maxWidth: "100%",
padding: "0",
border: "none",
background: "none",
@@ -496,14 +490,7 @@ export const lspTheme = EditorView.theme({
'.cm-lsp-inplace-suggestions button[aria-current="true"]': {
backgroundColor: "var(--bg-list-selected, var(--bg-tree-selected, var(--bg-selected-strong)))",
},
".cm-lsp-inplace-footer": {
display: "flex",
flexWrap: "wrap",
padding: "5px 12px",
gap: "var(--space-1) var(--space-3)",
justifyContent: "space-between",
overflowWrap: "anywhere",
},
".cm-lsp-inplace-footer": { overflowWrap: "anywhere" },
// --- floating lightbulb (intentions.ts) -----------------------------------
".cm-lsp-bulb": {
+118 -57
Переглянути файл
@@ -6,7 +6,16 @@
import { writeClipboardText } from "@/platform/clipboard";
import { isJvmApplication, parseJavaArgs } from "@/platform/javaLaunch";
import { useRunTargets } from "@/platform/pluginRunTargets";
import { useEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode, type RefObject } from "react";
import {
useEffect,
useMemo,
useRef,
useState,
type KeyboardEvent,
type MouseEvent,
type ReactNode,
type RefObject,
} from "react";
import clsx from "clsx";
import { isTauri, type BeforeLaunchTask, type BuildPolicy, type RunConfig } from "@/platform/ipc";
import { useWorkflowSettings } from "@/platform/workflowSettings";
@@ -54,6 +63,16 @@ import { TomcatSettings } from "./TomcatSettings";
import { toolWindowTitle } from "@/workbench/toolwindows/title";
import styles from "./Run.module.css";
const TASK_ICONS: Readonly<Partial<Record<string, string>>> = {
build: "build-project",
buildModule: "build-project",
buildArtifacts: "build-rebuild",
dotnetBuild: "build-project",
run: "run",
tool: "settings",
command: "terminal",
};
/**
* Debug adapters with a real launch template (`debugger/launch.ts`, `debugger/java.ts`),
* verified against small programs. Others (dart, …) only got
@@ -332,7 +351,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
const [envOpen, setEnvOpen] = useState(false);
const [modifyOpen, setModifyOpen] = useState(false);
const [lastRequest, setLastRequest] = useState(modifyRequest);
const [taskMenu, setTaskMenu] = useState(false);
const [taskMenu, setTaskMenu] = useState<"add" | { index: number; anchor: HTMLButtonElement } | null>(null);
const modifyRef = useRef<HTMLButtonElement>(null);
const taskRef = useRef<HTMLButtonElement>(null);
@@ -406,23 +425,23 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
run: () => addTask("run", c.id),
})),
},
{ label: TASK_LABELS.build, icon: "build-project", run: () => addTask("build") },
{ label: TASK_LABELS.build, icon: TASK_ICONS.build, run: () => addTask("build") },
{
label: TASK_LABELS.buildModule,
icon: "build-project",
icon: TASK_ICONS.buildModule,
disabled: config.module == null,
run: () => addTask("buildModule", config.module ?? ""),
},
{ label: TASK_LABELS.buildArtifacts, icon: "build-rebuild", run: () => addTask("buildArtifacts") },
{ label: TASK_LABELS.buildArtifacts, icon: TASK_ICONS.buildArtifacts, run: () => addTask("buildArtifacts") },
...(config.kind === "dotnet"
? [{ label: TASK_LABELS.dotnetBuild, icon: "build-project", run: () => addTask("dotnetBuild") }]
? [{ label: TASK_LABELS.dotnetBuild, icon: TASK_ICONS.dotnetBuild, run: () => addTask("dotnetBuild") }]
: []),
{
label: TASK_LABELS.tool,
disabled: !externalTools.length,
submenu: externalTools.map((t) => ({ label: t.name, verbatim: true, run: () => addTask("tool", t.id) })),
},
{ label: TASK_LABELS.command, icon: "terminal", run: () => addTask("command") },
{ label: TASK_LABELS.command, icon: TASK_ICONS.command, run: () => addTask("command") },
{
label: TASK_LABELS.toolWindow,
submenu: [...toolWindows.values()]
@@ -442,6 +461,7 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
[next[i], next[j]] = [next[j]!, next[i]!];
setTasks(next);
};
const taskActions = taskMenu === "add" ? null : taskMenu;
const adapterOptions: SelectOption[] = [
{ value: "", label: "None" },
@@ -763,62 +783,103 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
{isShown("beforeLaunch") && (
<Field label="Before launch" error={errors.beforeLaunch} top>
<div className={styles.taskList} role="list" aria-label={tx("Before launch tasks")}>
{tasks.map((t, i) => (
<div key={i} role="listitem" className={styles.taskRow}>
{t.kind === "command" ? (
<Input
mono
aria-label={txTemplate(`Before launch command ${i + 1}`)}
value={t.target ?? ""}
placeholder="Shell command, e.g. make generate"
onChange={(e) =>
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
}
/>
) : (
<span className={styles.taskLabel} title={txTemplate(taskLabel(t, all))}>
{txTemplate(taskLabel(t, all))}
</span>
)}
<span className={styles.taskActions}>
<div className={styles.beforeLaunchTasks} role="list" aria-label={tx("Before launch tasks")}>
{tasks.map((t, i) => {
const label = txTemplate(taskLabel(t, all));
const target = t.kind === "run" ? all.find((c) => c.id === t.target) : undefined;
const icon = target ? configIcon(target) : TASK_ICONS[t.kind];
const prefix = (
<>
{icon && <Icon name={icon} size={14} />}
<span className={styles.taskOrder}>{i + 1}.</span>
</>
);
const actions = {
"aria-haspopup": "menu" as const,
"aria-expanded": taskActions?.index === i,
onClick: (e: MouseEvent<HTMLButtonElement>) => setTaskMenu({ index: i, anchor: e.currentTarget }),
};
return (
<div key={i} role="listitem" className={styles.taskTag}>
{t.kind === "command" ? (
<>
{prefix}
<Input
mono
className={styles.taskCommand}
aria-label={txTemplate(`Before launch command ${i + 1}`)}
value={t.target ?? ""}
placeholder="Shell command, e.g. make generate"
onChange={(e) =>
setTasks(tasks.map((x, j) => (j === i ? { ...x, target: e.target.value } : x)))
}
/>
<IconButton icon="more" title="Task Actions" size="small" {...actions} />
</>
) : (
<button type="button" className={styles.taskName} title={label} {...actions}>
{prefix}
<span className={styles.taskLabel}>{label}</span>
</button>
)}
<IconButton
icon="arrow-up"
size="small"
iconSize={12}
title="Move Up"
disabled={i === 0}
onClick={() => moveTask(i, -1)}
/>
<IconButton
icon="arrow-down"
size="small"
iconSize={12}
title="Move Down"
disabled={i === tasks.length - 1}
onClick={() => moveTask(i, 1)}
/>
<IconButton
icon="minus"
icon="close"
size="small"
iconSize={12}
title="Remove Task"
onClick={() => setTasks(tasks.filter((_, j) => j !== i))}
/>
</span>
</div>
))}
<Button
ref={taskRef}
size="small"
variant="ghost"
icon="plus"
aria-haspopup="menu"
onClick={() => setTaskMenu(true)}
>
<T>Add task</T>
</Button>
<Menu open={taskMenu} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(false)} />
</div>
);
})}
<div role="listitem">
{tasks.length ? (
<IconButton
ref={taskRef}
title="Add task"
icon="plus"
size="small"
aria-haspopup="menu"
aria-expanded={taskMenu === "add"}
onClick={() => setTaskMenu("add")}
/>
) : (
<Button
ref={taskRef}
size="small"
variant="ghost"
icon="plus"
aria-haspopup="menu"
aria-expanded={taskMenu === "add"}
onClick={() => setTaskMenu("add")}
>
<T>Add task</T>
</Button>
)}
</div>
<Menu open={taskMenu === "add"} anchor={taskRef} items={taskItems} onClose={() => setTaskMenu(null)} />
{taskActions && (
<Menu
open
anchor={taskActions.anchor}
aria-label={tx("Task Actions")}
items={[
{
label: "Move Up",
icon: "arrow-up",
disabled: taskActions.index === 0,
run: () => moveTask(taskActions.index, -1),
},
{
label: "Move Down",
icon: "arrow-down",
disabled: taskActions.index === tasks.length - 1,
run: () => moveTask(taskActions.index, 1),
},
]}
onClose={() => setTaskMenu(null)}
/>
)}
</div>
</Field>
)}
+35 -2
Переглянути файл
@@ -958,10 +958,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;
+1
Переглянути файл
@@ -1,4 +1,5 @@
{
"Task Actions": "Task Actions",
"Search commits": "Search commits",
"Amend commit failed": "Amend commit failed",
"Amending this commit would cause a conflict. You can keep the prepared changes as a separate amend commit.": "Amending this commit would cause a conflict. You can keep the prepared changes as a separate amend commit.",
+1
Переглянути файл
@@ -4253,6 +4253,7 @@
"File relative to the project root": "相对于项目根目录的文件",
"Shell command, e.g. make generate": "Shell 命令,例如 make generate",
"Remove Task": "移除任务",
"Task Actions": "任务操作",
"Add task": "添加任务",
"Add configuration…": "添加配置…",
"Add configuration": "添加配置",