Skip to content

Commit a00a330

Browse files
committed
Add progress indicator for refresh and create environment
1 parent 6e5b27b commit a00a330

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

src/extension.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, ExtensionContext, LogOutputChannel, Terminal, Uri, window } from 'vscode';
1+
import { commands, ExtensionContext, l10n, LogOutputChannel, ProgressLocation, Terminal, Uri, window } from 'vscode';
22
import { version as extensionVersion } from '../package.json';
33
import { PythonEnvironment, PythonEnvironmentApi, PythonProjectCreator } from './api';
44
import { ensureCorrectVersion } from './common/extVersion';
@@ -16,6 +16,7 @@ import {
1616
createLogOutputChannel,
1717
onDidChangeActiveTerminal,
1818
onDidChangeTerminalShellIntegration,
19+
withProgress,
1920
} from './common/window.apis';
2021
import { getConfiguration } from './common/workspace.apis';
2122
import { createManagerReady } from './features/common/managerReady';
@@ -178,7 +179,15 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
178179
}),
179180
commands.registerCommand('python-envs.viewLogs', () => outputChannel.show()),
180181
commands.registerCommand('python-envs.refreshAllManagers', async () => {
181-
await Promise.all(envManagers.managers.map((m) => m.refresh(undefined)));
182+
await withProgress(
183+
{
184+
location: ProgressLocation.Notification,
185+
title: l10n.t('Refreshing environment managers...'),
186+
},
187+
async () => {
188+
await Promise.all(envManagers.managers.map((m) => m.refresh(undefined)));
189+
},
190+
);
182191
}),
183192
commands.registerCommand('python-envs.refreshPackages', async (item) => {
184193
await refreshPackagesCommand(item, envManagers);
@@ -193,18 +202,34 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
193202
manager: managerId,
194203
triggeredLocation: 'createSpecifiedCommand',
195204
});
196-
return await createEnvironmentCommand(item, envManagers, projectManager);
205+
return await withProgress(
206+
{
207+
location: ProgressLocation.Notification,
208+
title: l10n.t('Creating environment...'),
209+
},
210+
async () => {
211+
return await createEnvironmentCommand(item, envManagers, projectManager);
212+
},
213+
);
197214
}),
198215
commands.registerCommand('python-envs.createAny', async (options) => {
199216
// Telemetry: record environment creation attempt with no specific manager
200217
sendTelemetryEvent(EventNames.CREATE_ENVIRONMENT, undefined, {
201218
manager: 'none',
202219
triggeredLocation: 'createAnyCommand',
203220
});
204-
return await createAnyEnvironmentCommand(
205-
envManagers,
206-
projectManager,
207-
options ?? { selectEnvironment: true },
221+
return await withProgress(
222+
{
223+
location: ProgressLocation.Notification,
224+
title: l10n.t('Creating environment...'),
225+
},
226+
async () => {
227+
return await createAnyEnvironmentCommand(
228+
envManagers,
229+
projectManager,
230+
options ?? { selectEnvironment: true },
231+
);
232+
},
208233
);
209234
}),
210235
commands.registerCommand('python-envs.remove', async (item) => {

0 commit comments

Comments
 (0)