Файли
openidea/src/features/run/runTemplates.ts
T
arookieofc d018771a8d fix(run): Windows system python, pytest templates in gutter configs, pixi env detection (#1886)
* fix(run): use system python per OS and pytest templates, detect pixi envs

Gutter/context pytest configs on Windows used `python3`, which is not a
command there; fall back to `python` on Windows. Gutter-created pytest
configs now also inherit "Edit configuration templates... > pytest"
values via a template cache populated with the run configurations.

Pixi environments (`.pixi/envs/<env>`) are detected as the project's
Python: as run-configuration env (`PyEnv::Pixi`, tools via
`pixi run` or the env's own executables), as the project interpreter
for scripts/tests and the debugger, and as selectable SDKs, so the
interpreter picked in the IDE feeds completion.

Fixes l0ng-ai/openidea#1885

* fix(run): drop the pytest template's own target in gutter configs

testConfigFor always appends the gutter file, so a target stored on the
template would run twice (template target plus the file). The gutter file is
the target. Also corrects pixi_env's doc comment to the implemented name
order.
2026-11-07 05:32:45 +08:00

31 рядки
1.1 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/**
* A synchronous cache of the "Edit configuration templates…" values, so the
* run-context producers (gutter icons, ⌃⇧R) — which build configurations
* synchronously — can apply them. `loadConfigs` refreshes it from disk; the
* Edit Configurations dialog writes through it on save.
*/
import { call, commands, isTauri, type RunConfig } from "@/platform/ipc";
const cache = new Map<string, RunConfig>();
/** The stored template of `kind` ("Edit configuration templates…" › kind), if any. */
export function runTemplate(kind: string): RunConfig | undefined {
return cache.get(kind);
}
/** Caches the stored templates (called with `runTemplates()`'s result). */
export function cacheRunTemplates(templates: readonly RunConfig[]): void {
cache.clear();
for (const t of templates) cache.set(t.kind, t);
}
/** Refreshes the cache from disk; a no-op off the desktop. */
export async function loadRunTemplates(): Promise<void> {
if (!isTauri()) return;
try {
cacheRunTemplates(await call(commands.runTemplates()));
} catch {
/* keep the previous cache */
}
}