дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
fix(services): distinguish same-named configurations by module (#7999)
Part of #772. Co-authored-by: arookieofc <[email protected]> Co-authored-by: hpz <[email protected]>
Цей коміт міститься в:
2 files changed
+34
-1
No files matched your search
@@ -277,6 +277,22 @@ describe("run configurations in Services", () => {
|
||||
expect(runServiceItems([build], [], ["spring-boot"])[0]!.children).toEqual([]);
|
||||
});
|
||||
|
||||
it("shows same-named applications of several modules apart", () => {
|
||||
const app = (id: string, module: string): RunConfig => ({
|
||||
...config(id, "spring-boot"),
|
||||
name: "Application",
|
||||
module,
|
||||
});
|
||||
const items = runServiceItems(
|
||||
[app("application:svc-a:com.acme.Application", "svc-a"), app("application:svc-b:com.acme.Application", "svc-b")],
|
||||
[],
|
||||
["spring-boot"],
|
||||
);
|
||||
expect(items[0]!.children!.map((c) => c.label)).toEqual(["Application (svc-a)", "Application (svc-b)"]);
|
||||
const one = runServiceItems([app("application:api:com.acme.Application", "api")], [], ["spring-boot"]);
|
||||
expect(one[0]!.children!.map((c) => c.label)).toEqual(["Application"]);
|
||||
});
|
||||
|
||||
it("shows the HTTP port of a running application instead of its state", () => {
|
||||
const app = config("spring:app", "spring-boot");
|
||||
const running = session("s1", app, "running", 1, { httpPort: 8080 });
|
||||
|
||||
@@ -345,6 +345,22 @@ function executionDetail(s: ServiceSession | undefined): string | undefined {
|
||||
return s.run ? sessionDetail(s.run) : "Finished";
|
||||
}
|
||||
|
||||
/**
|
||||
* Labels of one type's configurations: a name used in several modules carries its module directory.
|
||||
*/
|
||||
function configLabels(entries: readonly RunConfig[]): Map<string, string> {
|
||||
const count = new Map<string, number>();
|
||||
for (const c of entries) count.set(c.name, (count.get(c.name) ?? 0) + 1);
|
||||
const labels = new Map<string, string>();
|
||||
for (const c of entries) {
|
||||
const relativeCwd =
|
||||
c.cwd && !c.cwd.startsWith("/") && !c.cwd.startsWith("\\") && !/^[A-Za-z]:/.test(c.cwd) ? c.cwd : null;
|
||||
const module = c.module ?? relativeCwd;
|
||||
labels.set(c.id, (count.get(c.name) ?? 0) > 1 && module ? `${c.name} (${module})` : c.name);
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Groups by configuration type, then by the configurations' folders (first, as in
|
||||
* Run/Debug Configurations): only the types added in this window list their
|
||||
@@ -372,11 +388,12 @@ export function runServiceItems(
|
||||
const hiddenIds = new Set(hidden[kind] ?? []);
|
||||
const visible = entries.filter((c) => !hiddenIds.has(c.id));
|
||||
const ordered = orderServices(visible, order[kind]);
|
||||
const labels = configLabels(visible);
|
||||
const item = (c: RunConfig): ServiceTreeItem => {
|
||||
const s = latest.get(c.id);
|
||||
return {
|
||||
key: CONFIG_PREFIX + c.id,
|
||||
label: c.name,
|
||||
label: labels.get(c.id) ?? c.name,
|
||||
icon: serviceDebugger(s) ? "debug" : s && liveServiceSession(s) ? "run" : configIcon(c),
|
||||
detail: executionDetail(s),
|
||||
dim: !s || !liveServiceSession(s),
|
||||
|
||||
Reference in new issue
Заблокувати користувача