Skip to content

Commit 1eaf5a3

Browse files
PopoDevKartik Raj
and
Kartik Raj
authored
Show name for conda environments created in the workspace (#22701)
fixes #21770 ![fix-update-conda-env-names](https://github.com/microsoft/vscode-python/assets/67870588/0b8906bc-232e-4880-afdf-5cc8adbf21bc) --------- Co-authored-by: Kartik Raj <[email protected]>
1 parent c09de84 commit 1eaf5a3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/client/pythonEnvironments/base/info/env.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ function buildEnvDisplayString(env: PythonEnvInfo, getAllDetails = false): strin
179179
const envSuffixParts: string[] = [];
180180
if (env.name && env.name !== '') {
181181
envSuffixParts.push(`'${env.name}'`);
182+
} else if (env.location && env.location !== '') {
183+
if (env.kind === PythonEnvKind.Conda) {
184+
const condaEnvName = path.basename(env.location);
185+
envSuffixParts.push(`'${condaEnvName}'`);
186+
}
182187
}
183188
if (shouldDisplayKind) {
184189
const kindName = getKindDisplayName(env.kind);

src/test/pythonEnvironments/base/info/env.unit.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ suite('Environment helpers', () => {
2222
version: parseVersionInfo('1.2.3')?.version,
2323
binDir: 'distroX/bin',
2424
};
25+
const locationConda1 = 'x/y/z/conda1';
26+
const locationConda2 = 'x/y/z/conda2';
27+
const kindConda = PythonEnvKind.Conda;
2528
function getEnv(info: {
2629
version?: string;
2730
arch?: Architecture;
@@ -65,6 +68,10 @@ suite('Environment helpers', () => {
6568
"Python 3.8.1 64-bit ('my-env')",
6669
"Python 3.8.1 64-bit ('my-env')",
6770
],
71+
// conda env.name is empty.
72+
[getEnv({ kind: kindConda }), 'Python', 'Python (conda)'],
73+
[getEnv({ location: locationConda1, kind: kindConda }), "Python ('conda1')", "Python ('conda1': conda)"],
74+
[getEnv({ location: locationConda2, kind: kindConda }), "Python ('conda2')", "Python ('conda2': conda)"],
6875
];
6976
return tests;
7077
}

0 commit comments

Comments
 (0)