дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-22 09:30:46 +02:00
Порівняти коміти
3
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
950c56234e | ||
|
|
e586923308 | ||
|
|
2ddc849b88 |
No files matched your search
@@ -841,10 +841,11 @@ fn a_reporting_task_outlives_its_background_budget() {
|
||||
|
||||
#[test]
|
||||
fn background_tasks_scale_and_renew_cpu_fuel_budget() {
|
||||
// Room for activation (about 3_100 on macOS, more on Windows) but not for `patient`'s
|
||||
// whole run (about 9_000) without the refill on each report.
|
||||
// Room for activation (about 3_100 on macOS, more on Windows). A background task gets ten
|
||||
// times it (5 s / 500 ms): enough for each step of `patient` with its CPU work (32_000 to
|
||||
// 80_000), not for the whole run without the refill on each report.
|
||||
let f = fixture(Limits {
|
||||
fuel: 6_000,
|
||||
fuel: 40_000,
|
||||
timeout: Duration::from_millis(500),
|
||||
background: Duration::from_millis(5_000),
|
||||
..Limits::default()
|
||||
@@ -856,11 +857,11 @@ fn background_tasks_scale_and_renew_cpu_fuel_budget() {
|
||||
// Warm up activation in its own call so `patient` starts with a fresh budget.
|
||||
assert_eq!(f.run("misbehave", "echo", Some("warm")).unwrap().as_deref(), Some("warm"));
|
||||
|
||||
let out = f.run("misbehave", "patient", None).expect("background task succeeds").expect("output");
|
||||
let out = f.run("misbehave", "patient", Some("4000")).expect("background task succeeds").expect("output");
|
||||
assert_eq!(out, "still here");
|
||||
|
||||
let err = f.run("misbehave", "spin", None).unwrap_err();
|
||||
assert!(err.contains("exceeded its CPU budget (6000 fuel per call)"), "{err}");
|
||||
assert!(err.contains("exceeded its CPU budget (40000 fuel per call)"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -2969,7 +2969,8 @@ async fn library_classes_without_sources_open_decompiled_by_a_running_jdtls() {
|
||||
zip.write_all(b"\0").unwrap();
|
||||
zip.finish().unwrap();
|
||||
let class = format!("jar://{}!/acme/Thing.class", uri_of(&jar).trim_start_matches("file://"));
|
||||
let escaped = jar.to_string_lossy().replace('/', "%5C/");
|
||||
// jdtls writes the portable path (forward slashes on Windows too), each `/` escaped.
|
||||
let escaped = jar.to_string_lossy().replace('\\', "/").replace('/', "%5C/");
|
||||
let jdt = format!("jdt://contents/lib-1.0.jar/acme/Thing.class?=app/{escaped}%3Cacme%28Thing.class");
|
||||
let decompiled =
|
||||
"package acme;\n\npublic class Thing {\n public void run() {\n System.out.println();\n }\n}\n";
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
6e1d2ff774cc8088b4b8a6766914a7f752d05657634e6934503cebd2aa241fa2
|
||||
9b5d0e40e7fef9e48e1a894549e4b96853b8217ad7d12fe29d238a599772a329
|
||||
@@ -180,8 +180,14 @@ impl commands::Guest for Misbehave {
|
||||
env: Vec::new(),
|
||||
};
|
||||
let child = process::start(&cmd, None)?;
|
||||
// CPU work per step (loop iterations), for fuel budget tests.
|
||||
let work: u64 = arg.as_deref().and_then(|a| a.parse().ok()).unwrap_or(0);
|
||||
for step in 0..25 {
|
||||
task.report(step, Some(25), Some("waiting"));
|
||||
let mut x: u64 = 0;
|
||||
for _ in 0..work {
|
||||
x = std::hint::black_box(x.wrapping_add(1));
|
||||
}
|
||||
// Waiting blocks in the host for 100 ms: wall time passes
|
||||
// while the plugin itself is not running.
|
||||
let _ = child.wait(100);
|
||||
|
||||
@@ -341,11 +341,13 @@ mod tests {
|
||||
{"lineNumber":41,"columnNumber":21,"source":{"path":"localhost꞉5173/src/App.vue","sourceReference":7}}]},
|
||||
{"locations":[{"lineNumber":10,"columnNumber":1,"source":{"path":"localhost꞉5173/","sourceReference":9}}]},
|
||||
{"locations":[]}]}}"#;
|
||||
let app = if cfg!(windows) { r"C:\work\shop\src\App.vue" } else { "/work/shop/src/App.vue" };
|
||||
let json = json.replace("\"/work/shop/src/App.vue\"", &serde_json::to_string(app).unwrap());
|
||||
let mut b = TreeBuilder::new();
|
||||
add_cpuprofile(&mut b, json).unwrap();
|
||||
add_cpuprofile(&mut b, &json).unwrap();
|
||||
let p = b.finish("node", "samples", ProfileMode::Cpu);
|
||||
let frame = |name: &str| p.frames.iter().find(|f| f.name == name).unwrap();
|
||||
assert_eq!(frame("increment").file.as_deref(), Some(Path::new("/work/shop/src/App.vue")));
|
||||
assert_eq!(frame("increment").file.as_deref(), Some(Path::new(app)));
|
||||
assert_eq!(frame("increment").line, Some(12));
|
||||
// No file on disk behind the frame: it stays without one.
|
||||
assert_eq!((frame("inline").file.as_deref(), frame("inline").line), (None, None));
|
||||
|
||||
@@ -2573,7 +2573,7 @@ fn a_member_without_python_falls_back_to_the_primary_project_interpreter() {
|
||||
assert_eq!(config.env["VIRTUAL_ENV"], outer.parent().unwrap().parent().unwrap().to_string_lossy());
|
||||
// Saving strips what settings derived, so the fallback keeps following settings.
|
||||
let stored = without_derived_in(&config, &bare, Some(&primary), &settings);
|
||||
assert_eq!(stored.command, exe("python"));
|
||||
assert_eq!(stored.command, "python", "the bare program, also on Windows");
|
||||
assert!(!stored.env.contains_key("VIRTUAL_ENV"));
|
||||
|
||||
// The member's explicit interpreter wins over the primary project's venv —
|
||||
|
||||
@@ -1119,7 +1119,8 @@ fn checkout_of_a_branch_held_by_another_worktree_reports_it_and_changes_nothing(
|
||||
fx.git(&["worktree", "add", "-q", "-b", "topic", linked.to_str().unwrap()]);
|
||||
let repo = fx.repo();
|
||||
let none = CheckoutOptions::default();
|
||||
let linked_path = std::fs::canonicalize(&linked).unwrap();
|
||||
// As git names it: no `\\?\` prefix on Windows.
|
||||
let linked_path = dunce::canonicalize(&linked).unwrap();
|
||||
|
||||
// From the main worktree, the branch the linked worktree has checked out.
|
||||
let outcome = repo.checkout_with("topic", false, &none).unwrap();
|
||||
@@ -1139,7 +1140,7 @@ fn checkout_of_a_branch_held_by_another_worktree_reports_it_and_changes_nothing(
|
||||
let linked_repo = Repo::discover(&linked).unwrap().unwrap();
|
||||
linked_repo.set_execution_allowed(true);
|
||||
let outcome = linked_repo.checkout_with("main", false, &none).unwrap();
|
||||
let main_path = std::fs::canonicalize(&fx.dir).unwrap();
|
||||
let main_path = dunce::canonicalize(&fx.dir).unwrap();
|
||||
assert_eq!(outcome, CheckoutOutcome::CheckedOutInWorktree { branch: "main".into(), path: main_path });
|
||||
assert_eq!(linked_repo.branch_info().unwrap().head.as_deref(), Some("topic"));
|
||||
|
||||
|
||||
@@ -255,7 +255,8 @@ async function selectDraft(page: Page) {
|
||||
}
|
||||
async function chooseModel(page: Page, name: string) {
|
||||
await modelButton(page).click();
|
||||
await page.getByRole("option", { name, exact: true }).click();
|
||||
// A model row also holds its Configure button, whose label joins the option's name.
|
||||
await page.getByRole("option", { name: new RegExp(`^${name}\\b`) }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await box(page).focus();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
Spinner,
|
||||
SymbolBadge,
|
||||
Tabs,
|
||||
showContextMenu,
|
||||
Tree,
|
||||
badgeKind,
|
||||
type TreeHandle,
|
||||
@@ -17,8 +18,11 @@ import {
|
||||
} from "@/ui";
|
||||
import { openLocation } from "./ipc";
|
||||
import {
|
||||
closeHierarchy,
|
||||
closeHierarchyTab,
|
||||
pinHierarchyTab,
|
||||
ROOT_ID,
|
||||
selectHierarchyTab,
|
||||
tabHierarchy,
|
||||
directionLabel,
|
||||
hierarchyTitle,
|
||||
hierarchyTarget,
|
||||
@@ -54,22 +58,44 @@ useHierarchyOptions.subscribe((s) => {
|
||||
}
|
||||
});
|
||||
|
||||
/** Tool window header: `Callers of foo` content tab. */
|
||||
/** Tool window header: the `Callers of foo` content tabs. */
|
||||
export function HierarchyTabs() {
|
||||
const mode = useHierarchy((s) => s.mode);
|
||||
const direction = useHierarchy((s) => s.direction);
|
||||
const root = useHierarchy((s) => s.root);
|
||||
if (!root) return null;
|
||||
const label = hierarchyTitle(mode, direction, root.name);
|
||||
const state = useHierarchy();
|
||||
const tabs = state.tabs.flatMap((tab) => {
|
||||
const h = tabHierarchy(state, tab);
|
||||
return h.root ? [{ tab, label: hierarchyTitle(h.mode, h.direction, h.root.name) }] : [];
|
||||
});
|
||||
if (!tabs.length || state.active === null) return null;
|
||||
return (
|
||||
<Tabs
|
||||
variant="compact"
|
||||
className={styles.tabs}
|
||||
aria-label="Hierarchies"
|
||||
items={[{ id: "current", label, closable: true }]}
|
||||
activeId="current"
|
||||
onSelect={() => undefined}
|
||||
onClose={closeHierarchy}
|
||||
items={tabs.map(({ tab, label }) => ({ id: String(tab.id), label, closable: true, pinned: tab.pinned }))}
|
||||
activeId={String(state.active)}
|
||||
onSelect={(id) => selectHierarchyTab(Number(id))}
|
||||
onClose={(id) => closeHierarchyTab(Number(id))}
|
||||
onTogglePin={(id) => {
|
||||
const tab = tabs.find((t) => t.tab.id === Number(id))?.tab;
|
||||
if (tab) pinHierarchyTab(tab.id, !tab.pinned);
|
||||
}}
|
||||
onContextMenu={(id, e) => {
|
||||
const tab = tabs.find((t) => t.tab.id === Number(id))?.tab;
|
||||
if (!tab) return;
|
||||
// IDEA's content tab menu.
|
||||
showContextMenu(e, [
|
||||
{ id: "close", label: "Close Tab", run: () => closeHierarchyTab(tab.id) },
|
||||
{ id: "closeAll", label: "Close All Tabs", run: () => tabs.forEach((t) => closeHierarchyTab(t.tab.id)) },
|
||||
{
|
||||
id: "closeOthers",
|
||||
label: "Close Other Tabs",
|
||||
disabled: tabs.length < 2,
|
||||
run: () => tabs.forEach((t) => t.tab.id !== tab.id && closeHierarchyTab(t.tab.id)),
|
||||
},
|
||||
{ kind: "separator" },
|
||||
{ id: "pin", label: tab.pinned ? "Unpin Tab" : "Pin Tab", run: () => pinHierarchyTab(tab.id, !tab.pinned) },
|
||||
]);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -114,7 +140,7 @@ function HierarchyToolbar() {
|
||||
}
|
||||
|
||||
export function HierarchyView() {
|
||||
const { mode, direction, root, children, failed, notes, loading, generation } = useHierarchy();
|
||||
const { mode, direction, root, children, failed, notes, loading, expanded, generation } = useHierarchy();
|
||||
const projectRoot = useProject((s) => s.project?.root ?? "");
|
||||
const roots = useMemo<Node[]>(() => (root ? [{ kind: "root", id: ROOT_ID }] : []), [root]);
|
||||
|
||||
@@ -224,11 +250,12 @@ export function HierarchyView() {
|
||||
getChildren={getChildren}
|
||||
isExpandable={isExpandable}
|
||||
loadChildren={(n) => (n.kind === "item" ? loadChildren(n.node) : undefined)}
|
||||
onExpandedChange={(_expanded, n, open) => {
|
||||
onExpandedChange={(opened, n, open) => {
|
||||
useHierarchy.setState({ expanded: [...opened] });
|
||||
const shown = open ? children.get(n.id) : undefined;
|
||||
if (shown) prefetchLevels(shown);
|
||||
}}
|
||||
defaultExpanded={[ROOT_ID]}
|
||||
defaultExpanded={expanded}
|
||||
handleRef={tree}
|
||||
isOccurrence={() => true}
|
||||
onSelectionChange={(_sel, n) => {
|
||||
|
||||
@@ -306,3 +306,45 @@ describe("closing the hierarchy tab", () => {
|
||||
expect(hide).toHaveBeenCalledWith("hierarchy", { removeFromStripe: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe("hierarchy tabs", () => {
|
||||
it("replace the selected tab unless it is pinned, and keep each tab's tree", async () => {
|
||||
const { closeHierarchyTab, pinHierarchyTab, selectHierarchyTab, tabHierarchy } = await import("./hierarchy");
|
||||
const names = () => {
|
||||
const s = useHierarchy.getState();
|
||||
return s.tabs.map((t) => `${tabHierarchy(s, t).mode}:${t.pinned ? "pinned" : ""}`);
|
||||
};
|
||||
resetHierarchy();
|
||||
await showHierarchy("call");
|
||||
await showHierarchy("type");
|
||||
expect(names()).toEqual(["type:"]);
|
||||
const first = useHierarchy.getState().active!;
|
||||
pinHierarchyTab(first, true);
|
||||
await showHierarchy("call");
|
||||
expect(names()).toEqual(["type:pinned", "call:"]);
|
||||
const second = useHierarchy.getState().active!;
|
||||
expect(
|
||||
useHierarchy
|
||||
.getState()
|
||||
.children.get(ROOT_ID)
|
||||
?.map((n) => n.item.name),
|
||||
).toEqual(["main"]);
|
||||
|
||||
selectHierarchyTab(first);
|
||||
expect(useHierarchy.getState().mode).toBe("type");
|
||||
selectHierarchyTab(second);
|
||||
expect(useHierarchy.getState().mode).toBe("call");
|
||||
expect(
|
||||
useHierarchy
|
||||
.getState()
|
||||
.children.get(ROOT_ID)
|
||||
?.map((n) => n.item.name),
|
||||
).toEqual(["main"]);
|
||||
|
||||
closeHierarchyTab(second);
|
||||
expect(useHierarchy.getState()).toMatchObject({ active: first, mode: "type" });
|
||||
expect(names()).toEqual(["type:pinned"]);
|
||||
closeHierarchyTab(first);
|
||||
expect(useHierarchy.getState()).toMatchObject({ root: null, tabs: [], active: null });
|
||||
});
|
||||
});
|
||||
@@ -54,8 +54,27 @@ interface HierarchyState {
|
||||
/** Parent id → why its children may be missing callers. */
|
||||
notes: ReadonlyMap<string, string>;
|
||||
loading: boolean;
|
||||
/** Ids of the expanded nodes, so a tab shown again keeps its tree open. */
|
||||
expanded: readonly string[];
|
||||
/** Bumped per (re)query so stale responses are dropped and the tree resets. */
|
||||
generation: number;
|
||||
/** Content tabs; the selected one's hierarchy is the state above. */
|
||||
tabs: readonly HierarchyTab[];
|
||||
active: number | null;
|
||||
}
|
||||
|
||||
/** The hierarchy of a tab that isn't selected. */
|
||||
export type SavedHierarchy = Pick<
|
||||
HierarchyState,
|
||||
"mode" | "direction" | "root" | "children" | "failed" | "notes" | "loading" | "expanded"
|
||||
>;
|
||||
|
||||
export interface HierarchyTab {
|
||||
id: number;
|
||||
/** Pinned: a new hierarchy opens beside it instead of taking its place. */
|
||||
pinned: boolean;
|
||||
/** Null for the selected tab. */
|
||||
saved: SavedHierarchy | null;
|
||||
}
|
||||
|
||||
export const ROOT_ID = "root";
|
||||
@@ -68,9 +87,89 @@ export const useHierarchy = create<HierarchyState>(() => ({
|
||||
failed: new Set(),
|
||||
notes: new Map(),
|
||||
loading: false,
|
||||
expanded: [ROOT_ID],
|
||||
generation: 0,
|
||||
tabs: [],
|
||||
active: null,
|
||||
}));
|
||||
|
||||
let tabSeq = 0;
|
||||
|
||||
function saved(s: HierarchyState): SavedHierarchy {
|
||||
const { mode, direction, root, children, failed, notes, loading, expanded } = s;
|
||||
return { mode, direction, root, children, failed, notes, loading, expanded };
|
||||
}
|
||||
|
||||
/** A tab's mode, direction and root: the live state's for the selected one. */
|
||||
export function tabHierarchy(s: HierarchyState, tab: HierarchyTab): SavedHierarchy {
|
||||
return tab.saved ?? saved(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* As IDEA: a new hierarchy takes the place of the selected tab unless it is pinned,
|
||||
* then it opens in a tab of its own.
|
||||
*/
|
||||
function openTab() {
|
||||
const s = useHierarchy.getState();
|
||||
const current = s.tabs.find((t) => t.id === s.active);
|
||||
if (current && !current.pinned) return;
|
||||
cancelInflight();
|
||||
const id = ++tabSeq;
|
||||
useHierarchy.setState({
|
||||
tabs: [
|
||||
...s.tabs.map((t) => (t.id === s.active ? { ...t, saved: saved(s) } : t)),
|
||||
{ id, pinned: false, saved: null },
|
||||
],
|
||||
active: id,
|
||||
root: null,
|
||||
children: new Map(),
|
||||
failed: new Set(),
|
||||
notes: new Map(),
|
||||
loading: false,
|
||||
expanded: [ROOT_ID],
|
||||
generation: s.generation + 1,
|
||||
});
|
||||
}
|
||||
|
||||
export function selectHierarchyTab(id: number) {
|
||||
const s = useHierarchy.getState();
|
||||
const target = s.tabs.find((t) => t.id === id);
|
||||
if (id === s.active || !target?.saved) return;
|
||||
cancelInflight();
|
||||
const next = target.saved;
|
||||
useHierarchy.setState({
|
||||
...next,
|
||||
loading: false,
|
||||
generation: s.generation + 1,
|
||||
active: id,
|
||||
tabs: s.tabs.map((t) => (t.id === s.active ? { ...t, saved: saved(s) } : t.id === id ? { ...t, saved: null } : t)),
|
||||
});
|
||||
// Its requests were dropped when it was left: load it again.
|
||||
if (next.loading) void loadRoot();
|
||||
}
|
||||
|
||||
/** Closes a tab; the tool window goes with the last one. */
|
||||
export function closeHierarchyTab(id: number) {
|
||||
const s = useHierarchy.getState();
|
||||
const at = s.tabs.findIndex((t) => t.id === id);
|
||||
if (at < 0) return;
|
||||
const rest = s.tabs.filter((t) => t.id !== id);
|
||||
if (!rest.length) {
|
||||
closeHierarchy();
|
||||
return;
|
||||
}
|
||||
if (id !== s.active) {
|
||||
useHierarchy.setState({ tabs: rest });
|
||||
return;
|
||||
}
|
||||
useHierarchy.setState({ tabs: rest, active: null });
|
||||
selectHierarchyTab((s.tabs[at + 1] ?? s.tabs[at - 1])!.id);
|
||||
}
|
||||
|
||||
export function pinHierarchyTab(id: number, pinned: boolean) {
|
||||
useHierarchy.setState((s) => ({ tabs: s.tabs.map((t) => (t.id === id ? { ...t, pinned } : t)) }));
|
||||
}
|
||||
|
||||
/** Call hierarchy requests the current tree still waits for. */
|
||||
const inflight = new Set<RequestId>();
|
||||
|
||||
@@ -88,7 +187,10 @@ export function resetHierarchy() {
|
||||
failed: new Set(),
|
||||
notes: new Map(),
|
||||
loading: false,
|
||||
expanded: [ROOT_ID],
|
||||
generation: s.generation + 1,
|
||||
tabs: [],
|
||||
active: null,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -248,7 +350,14 @@ async function loadRoot(quiet = false): Promise<RootResult> {
|
||||
if (!root) return "stale";
|
||||
const generation = s.generation + 1;
|
||||
cancelInflight();
|
||||
useHierarchy.setState({ generation, children: new Map(), failed: new Set(), notes: new Map(), loading: true });
|
||||
useHierarchy.setState({
|
||||
generation,
|
||||
children: new Map(),
|
||||
failed: new Set(),
|
||||
notes: new Map(),
|
||||
loading: true,
|
||||
expanded: [ROOT_ID],
|
||||
});
|
||||
try {
|
||||
const { items, incomplete } = await withDocument(root.path, (doc) =>
|
||||
request(s.mode, doc, root.path, root.line, root.col, s.direction),
|
||||
@@ -365,6 +474,7 @@ export async function showHierarchy(mode: HierarchyMode) {
|
||||
hint("Open a file to show the hierarchy");
|
||||
return;
|
||||
}
|
||||
openTab();
|
||||
const s = useHierarchy.getState();
|
||||
const direction = s.mode === mode ? s.direction : mode === "call" ? "incoming" : "outgoing";
|
||||
useHierarchy.setState({
|
||||
|
||||
@@ -69,3 +69,14 @@ it("keeps an agent's commands out of other tabs", async () => {
|
||||
await startRun(agent, undefined, undefined, { prepared: true });
|
||||
expect(useRun.getState().sessions).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("gives runs started together their own tabs", async () => {
|
||||
useRun.setState({ sessions: [finished("a"), finished("b")], activeSession: "a" });
|
||||
await Promise.all([
|
||||
startRun(config("x"), "a", undefined, { prepared: true }),
|
||||
startRun(config("y"), undefined, undefined, { prepared: true }),
|
||||
startRun(config("z"), undefined, undefined, { prepared: true }),
|
||||
]);
|
||||
expect(tabs()).toEqual(["a:x", "b:y", expect.stringMatching(/^run\d+:z$/)]);
|
||||
expect(ipc.runStart).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
@@ -760,38 +760,58 @@ export function sessionsOf(config: RunConfig, sessions = useRun.getState().sessi
|
||||
* Agents' commands keep to their own tabs.
|
||||
*/
|
||||
function reusableTab(sessions: readonly RunSession[], active: string | null, config: RunConfig) {
|
||||
const free = sessions.filter((s) => !isLive(s) && !s.pinned);
|
||||
const free = sessions.filter((s) => !isLive(s) && !s.pinned && !claimedTabs.has(s.id));
|
||||
const same = free.find((s) => s.config.id === config.id);
|
||||
if (same || agentName(config) !== null) return same;
|
||||
const others = free.filter((s) => agentName(s.config) === null);
|
||||
return others.find((s) => s.id === active) ?? others[0];
|
||||
}
|
||||
|
||||
/** Tabs a starting run is about to take: runs started together (compounds, reruns of several packages) must not take the same one. */
|
||||
const claimedTabs = new Set<string>();
|
||||
|
||||
/** Pins or unpins a session's tab. */
|
||||
export function pinSession(id: string, pinned: boolean) {
|
||||
patchSession(id, { pinned });
|
||||
}
|
||||
|
||||
interface StartRunOptions {
|
||||
show?: boolean;
|
||||
/** Launch this instead of `config` (e.g. with a debug agent); the tab still shows `config`. Skips before launch tasks. */
|
||||
launch?: RunConfig;
|
||||
/** Every output line of this run. */
|
||||
onLine?: (text: string) => void;
|
||||
/** The process exited. */
|
||||
onExit?: (exitCode: number | null, stopped: boolean) => void;
|
||||
/** Before launch tasks already ran (or must not run). */
|
||||
prepared?: boolean;
|
||||
/** Configurations whose launch led to this one (before launch tasks, compounds): breaks cycles. */
|
||||
chain?: readonly string[];
|
||||
/** Runs before the stop signal when the user stops this run (run executors). */
|
||||
beforeStop?: (runId: RunId) => Promise<void>;
|
||||
}
|
||||
|
||||
/** Starts `config`, reusing the tab of a finished (or the given) session (see `reusableTab`). */
|
||||
export async function startRun(
|
||||
config: RunConfig,
|
||||
reuse?: string,
|
||||
baseConfig?: RunConfig,
|
||||
options: {
|
||||
show?: boolean;
|
||||
/** Launch this instead of `config` (e.g. with a debug agent); the tab still shows `config`. Skips before launch tasks. */
|
||||
launch?: RunConfig;
|
||||
/** Every output line of this run. */
|
||||
onLine?: (text: string) => void;
|
||||
/** The process exited. */
|
||||
onExit?: (exitCode: number | null, stopped: boolean) => void;
|
||||
/** Before launch tasks already ran (or must not run). */
|
||||
prepared?: boolean;
|
||||
/** Configurations whose launch led to this one (before launch tasks, compounds): breaks cycles. */
|
||||
chain?: readonly string[];
|
||||
/** Runs before the stop signal when the user stops this run (run executors). */
|
||||
beforeStop?: (runId: RunId) => Promise<void>;
|
||||
} = {},
|
||||
options: StartRunOptions = {},
|
||||
): Promise<RunSession | null> {
|
||||
if (!reuse || claimedTabs.has(reuse)) return startRunIn(config, reuse, baseConfig, options);
|
||||
claimedTabs.add(reuse);
|
||||
try {
|
||||
return await startRunIn(config, reuse, baseConfig, options);
|
||||
} finally {
|
||||
claimedTabs.delete(reuse);
|
||||
}
|
||||
}
|
||||
|
||||
async function startRunIn(
|
||||
config: RunConfig,
|
||||
reuse: string | undefined,
|
||||
baseConfig: RunConfig | undefined,
|
||||
options: StartRunOptions,
|
||||
): Promise<RunSession | null> {
|
||||
config = withRunTarget(config);
|
||||
if (!options.launch && isCMakeBuild(config)) {
|
||||
@@ -841,12 +861,16 @@ export async function startRun(
|
||||
// IDEA there is no time limit: a first Stop waits for the shutdown, a second one kills it.
|
||||
await waitForExit(stopping, null);
|
||||
const now = useRun.getState();
|
||||
session ??= reusableTab(now.sessions, now.activeSession, config);
|
||||
const picked = session ? undefined : reusableTab(now.sessions, now.activeSession, config);
|
||||
session ??= picked;
|
||||
|
||||
if (picked) claimedTabs.add(picked.id);
|
||||
try {
|
||||
await maybeEditorService()?.saveAll();
|
||||
} catch {
|
||||
/* saving is best effort */
|
||||
} finally {
|
||||
if (picked) claimedTabs.delete(picked.id);
|
||||
}
|
||||
|
||||
const startedAt = Date.now();
|
||||
|
||||
Reference in new issue
Заблокувати користувача