feat(run): reuse the configuration of a main class run from its context (#783)

Running or debugging a main class from the editor, gutter or Project view now selects an existing saved Application or Spring Boot configuration of the same main class and module, keeping its VM options, environment and profiles, instead of creating a temporary one.

Co-authored-by: ntbang0901 <[email protected]>
This commit is contained in:
ntbang0901 authored and GitHub committed 2026-11-02 14:57:15 +08:00
1 parent 47f68862c8
commit a8e12ff7c4
2 files changed
+30 -1

No files matched your search

+19
View File
@@ -395,6 +395,25 @@ describe("temporary configurations", () => {
expect(useRun.getState().temporary).toEqual([]);
});
it("reuse a configuration of the same main class and module, whatever its id", () => {
const own = (module: string) =>
cfg({
id: `user:${module}`,
kind: "spring-boot",
name: `Mine ${module}`,
args: ["-Xmx1g", "-cp", "${classpath}", "a.Main"],
module,
detected: false,
});
useRun.setState({ configs: [own("other"), own("app")] });
expect(adoptTemporary(applicationConfig({ className: "a.Main" }, "app/src/main/java/a/Main.java")).name).toBe(
"Mine app",
);
expect(useRun.getState().temporary).toEqual([]);
const fresh = adoptTemporary(applicationConfig({ className: "a.Other" }, "app/src/main/java/a/Other.java"));
expect(useRun.getState().temporary).toEqual([fresh.id]);
});
it("offer Save in the chooser while selected", async () => {
const app = adoptTemporary(applicationConfig({ className: "a.Main" }, "src/main/java/a/Main.java"));
const { configs, temporary } = useRun.getState();