From be83458161dff154bfb91240e2b1dde743eba9a5 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Fri, 27 Nov 2026 16:17:30 +0900 Subject: [PATCH] feat(run): choose the Python interpreter of a run configuration from a list (#6382) Python and Django test run configurations get an Interpreter dropdown: Project default, each detected interpreter (minus those removed on All Interpreters), or Custom command, which shows the Command field for runners such as uv or poetry. The chosen interpreter's path is stored as the command, so command lines, the backend and .run.xml import are unchanged; existing configurations open with the choice their command stands for, and a missing interpreter is shown as not found. With a run-target project interpreter only Project default and Custom command are offered. RunConfigTypeField gains an optional set(value, params) so a select can stand for other params. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- src/features/run/ConfigForm.tsx | 14 ++- src/features/run/djangoTypes.ts | 3 + src/features/run/pythonInterpreter.test.tsx | 128 ++++++++++++++++++++ src/features/run/pythonTypes.ts | 82 ++++++++++++- src/platform/locales/text/en.json | 5 +- src/platform/locales/text/zh.json | 5 +- src/workbench/contributions.ts | 14 ++- 7 files changed, 240 insertions(+), 11 deletions(-) create mode 100644 src/features/run/pythonInterpreter.test.tsx diff --git a/src/features/run/ConfigForm.tsx b/src/features/run/ConfigForm.tsx index 65e4ff7597..cbb8166dae 100644 --- a/src/features/run/ConfigForm.tsx +++ b/src/features/run/ConfigForm.tsx @@ -618,7 +618,9 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi params={params} all={all} invalid={!!errors[f.key]} - onChange={(v) => setParam(f.key, v)} + onChange={(v) => + f.set ? onChange(withParams(config, f.set(v, params), type)) : setParam(f.key, v) + } /> )) @@ -971,24 +973,26 @@ function TypeField({ const root = useProject((s) => s.project?.root ?? null); const listId = `run-field-${field.key}`; const [loaded, setLoaded] = useState>([]); + // A select that stands for other params shows the value worked out from them. + const shown = field.control === "select" && field.value ? field.value(params) : value; useEffect(() => { let live = true; void field - .loadOptions?.() + .loadOptions?.(shown) .then((options) => live && setLoaded(options)) .catch(() => {}); return () => { live = false; }; - }, [field]); + }, [field, shown]); if (field.control === "output") return ; if (field.control === "select") { // Loaded options are detected data (JDKs, build modules), not catalog text. const options: SelectOption[] = [...(field.options ?? []), ...loaded.map((o) => ({ ...o, verbatim: true }))]; - if (value && !options.some((o) => o.value === value)) options.push({ value, label: value, verbatim: true }); + if (shown && !options.some((o) => o.value === shown)) options.push({ value: shown, label: shown, verbatim: true }); return (