Skip to content

Commit 01eda1e

Browse files
authored
fix: quick Create ux tweaks and clean up (#308)
1 parent 22f08ae commit 01eda1e

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export interface EnvironmentManager {
374374

375375
/**
376376
* The quick create details for the environment manager. Having this method also enables the quick create feature
377-
* for the environment manager.
377+
* for the environment manager. Should Implement {@link EnvironmentManager.create} to support quick create.
378378
*/
379379
quickCreateConfig?(): QuickCreateConfig | undefined;
380380

src/common/pickers/managers.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ export async function pickEnvironmentManager(
3737
kind: QuickPickItemKind.Separator,
3838
});
3939
if (defaultManagers.length === 1 && defaultManagers[0].supportsQuickCreate) {
40-
const details = defaultManagers[0].quickCreateConfig();
40+
const defaultMgr = defaultManagers[0];
41+
const details = defaultMgr.quickCreateConfig();
4142
if (details) {
4243
items.push({
4344
label: Common.quickCreate,
44-
description: details.description,
45+
description: `${defaultMgr.displayName}${details.description}`,
4546
detail: details.detail,
46-
id: `QuickCreate#${defaultManagers[0].id}`,
47+
id: `QuickCreate#${defaultMgr.id}`,
4748
});
4849
}
4950
}

src/internal.api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ export class InternalEnvironmentManager implements EnvironmentManager {
155155
}
156156

157157
public get supportsQuickCreate(): boolean {
158-
return this.manager.quickCreateConfig !== undefined;
158+
return this.manager.quickCreateConfig !== undefined && this.manager.create !== undefined;
159159
}
160160

161161
quickCreateConfig(): QuickCreateConfig | undefined {
162-
if (this.manager.quickCreateConfig) {
162+
if (this.manager.quickCreateConfig && this.manager.create) {
163163
return this.manager.quickCreateConfig();
164164
}
165165
throw new CreateEnvironmentNotSupported(`Quick Create Environment not supported by: ${this.id}`);

src/managers/builtin/venvManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import * as path from 'path';
3636
import { NativePythonFinder } from '../common/nativePythonFinder';
3737
import { PYTHON_EXTENSION_ID } from '../../common/constants';
3838
import { createDeferred, Deferred } from '../../common/utils/deferred';
39-
import { getLatest, sortEnvironments } from '../common/utils';
39+
import { getLatest, shortVersion, sortEnvironments } from '../common/utils';
4040
import { withProgress } from '../../common/window.apis';
4141
import { VenvManagerStrings } from '../../common/localize';
4242
import { showErrorMessage } from '../../common/errors/utils';
@@ -98,7 +98,10 @@ export class VenvManager implements EnvironmentManager {
9898

9999
return {
100100
description: l10n.t('Create a virtual environment in workspace root'),
101-
detail: l10n.t('Uses Python version {0} and installs workspace dependencies.', this.globalEnv.version),
101+
detail: l10n.t(
102+
'Uses Python version {0} and installs workspace dependencies.',
103+
shortVersion(this.globalEnv.version),
104+
),
102105
};
103106
}
104107

src/managers/common/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export function shortVersion(version: string): string {
7373
}
7474
return version;
7575
}
76+
7677
export function isGreater(a: string | undefined, b: string | undefined): boolean {
7778
if (!a && !b) {
7879
return false;

src/managers/conda/condaEnvManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
128128
}
129129

130130
return {
131-
description: l10n.t('Create a conda virtual environment in workspace root'),
131+
description: l10n.t('Create a conda environment'),
132132
detail: l10n.t('Uses Python version {0} and installs workspace dependencies.', this.globalEnv.version),
133133
};
134134
}

0 commit comments

Comments
 (0)