feat(debug): debug programs in a plugin run target (#2264)

Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-09 12:52:41 +08:00
1 джерело 0ccc1e687d
коміт 542584abb8
70 files changed
+709 -62

No files matched your search

+16 -4
Переглянути файл
@@ -1,4 +1,5 @@
/** Debugger actions (ids match `keymaps/intellij-macos.ts`). */
import { withRunTarget } from "@/platform/runTargetSelection";
import { executeAction, getAction, registerActions, type Action } from "@/platform/actions";
import {
call,
@@ -315,11 +316,12 @@ async function startConfig(arg: unknown) {
return;
}
}
if (isRemoteConfig(config)) {
config = withRunTarget(config);
if (!config.target?.startsWith("plugin-target:") && isRemoteConfig(config)) {
await startRemote(config, root, show);
return;
}
if (isJavaDebuggable(config)) {
if (!config.target?.startsWith("plugin-target:") && isJavaDebuggable(config)) {
await startJavaConfig(config, root, origin ?? config, show);
return;
}
@@ -339,11 +341,21 @@ async function startConfig(arg: unknown) {
});
return;
}
const xdebugCheck = config.debugAdapter === "php-debug" && isTauri() ? warnWithoutXdebug(launch) : null;
const pluginTarget = config.target?.startsWith("plugin-target:");
if (pluginTarget) {
const extra = JSON.parse(launch.extraJson ?? "{}");
extra.__runTarget = config.target;
launch.extraJson = JSON.stringify(extra);
}
const xdebugCheck =
!pluginTarget && config.debugAdapter === "php-debug" && isTauri() ? warnWithoutXdebug(launch) : null;
await maybeEditorService()
?.saveAll()
.catch(() => undefined);
await startSession(launch, { runConfig: origin ?? config, show });
const started = await startSession(launch, { runConfig: origin ?? config, show });
if (started && pluginTarget && config.debugAdapter === "php-debug") {
await executeAction("run.runConfig", config);
}
await xdebugCheck;
}
+6
Переглянути файл
@@ -2,6 +2,7 @@
* Run configurations, the title bar run widget, the Run tool window (console +
* test runner) and run/debug/stop actions.
*/
import { withRunTarget } from "@/platform/runTargetSelection";
import { registerEditorContribution } from "@/editor/api";
import { executeAction, executeActionOrThrow, getAction, registerActions } from "@/platform/actions";
import { getContext, setContext, useContextKeys } from "@/platform/context";
@@ -146,6 +147,7 @@ async function runSelected() {
}
async function debugConfig(config: RunConfig, chain: readonly string[] = [], show?: boolean) {
config = withRunTarget(config);
if (config.kind === "compound") {
if (!(await prepareLaunch(config, chain, show))) return;
const children = compoundChildren(config, useRun.getState().configs);
@@ -155,6 +157,10 @@ async function debugConfig(config: RunConfig, chain: readonly string[] = [], sho
if (remoteDebugBlocked(config)) return;
if (!(await prepareLaunch(config, chain, show))) return;
recordRun(config.id);
if (config.target?.startsWith("plugin-target:")) {
await executeAction("debug.startConfig", show === false ? { config, show: false } : config);
return;
}
// Python on a Docker / Compose target: debugpy in the container, the debugger attaches.
if (containerDebuggable(config) && getAction("debug.attach")) {
await debugInContainer(config);
+8
Переглянути файл
@@ -217,6 +217,14 @@ describe("remote debugging", () => {
);
});
it("dispatches plugin targets to the target-aware debugger", async () => {
const config = cfg("app", { target: "plugin-target:4:wrapper", debugAdapter: "debugpy" });
useRun.setState({ configs: [config], loaded: true });
await executeAction("run.debugConfig", config.id);
expect(startConfig).toHaveBeenCalledWith(config);
expect(remoteDebugBlocked(config)).toBe(false);
});
describe("in containers", () => {
const container: RunTargetValid = { ...DEFAULT_RUN_TARGET, kind: "docker", id: "py", name: "Python", image: "x" };
const attach = vi.fn();
+2 -1
Переглянути файл
@@ -69,7 +69,8 @@ export function containerDebuggable(
*/
export function remoteDebugBlocked(config: RunConfig, targets: readonly RuntimeRunTarget[] = allRunTargets()): boolean {
config = withRunTarget(config);
if (!config.target || containerDebuggable(config, targets)) return false;
if (!config.target || config.target.startsWith("plugin-target:") || containerDebuggable(config, targets))
return false;
const target = targetName(config, targets) ?? config.target;
const container = targetOf(config, targets);
notifications().notify({