Skip to content

Commit b2216dc

Browse files
committed
Progress indicator for refresh and create env
1 parent 1e25bbb commit b2216dc

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

src/extension.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, ExtensionContext, extensions, LogOutputChannel, Terminal, Uri, window } from 'vscode';
1+
import { commands, ExtensionContext, extensions, l10n, LogOutputChannel, ProgressLocation, Terminal, Uri, window } from 'vscode';
22
import { PythonEnvironment, PythonEnvironmentApi, PythonProjectCreator } from './api';
33
import { ENVS_EXTENSION_ID } from './common/constants';
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';
@@ -181,9 +182,15 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
181182
}),
182183
commands.registerCommand('python-envs.viewLogs', () => outputChannel.show()),
183184
commands.registerCommand('python-envs.refreshAllManagers', async () => {
184-
await window.withProgress({ location: { viewId: 'env-managers' } }, async () => {
185-
await Promise.all(envManagers.managers.map((m) => m.refresh(undefined)));
186-
});
185+
await withProgress(
186+
{
187+
location: ProgressLocation.Notification,
188+
title: l10n.t('Refreshing environment managers...'),
189+
},
190+
async () => {
191+
await Promise.all(envManagers.managers.map((m) => m.refresh(undefined)));
192+
},
193+
);
187194
}),
188195
commands.registerCommand('python-envs.searchSettings', async () => {
189196
await openSearchSettings();
@@ -201,18 +208,34 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
201208
manager: managerId,
202209
triggeredLocation: 'createSpecifiedCommand',
203210
});
204-
return await createEnvironmentCommand(item, envManagers, projectManager);
211+
return await withProgress(
212+
{
213+
location: ProgressLocation.Notification,
214+
title: l10n.t('Creating environment...'),
215+
},
216+
async () => {
217+
return await createEnvironmentCommand(item, envManagers, projectManager);
218+
},
219+
);
205220
}),
206221
commands.registerCommand('python-envs.createAny', async (options) => {
207222
// Telemetry: record environment creation attempt with no specific manager
208223
sendTelemetryEvent(EventNames.CREATE_ENVIRONMENT, undefined, {
209224
manager: 'none',
210225
triggeredLocation: 'createAnyCommand',
211226
});
212-
return await createAnyEnvironmentCommand(
213-
envManagers,
214-
projectManager,
215-
options ?? { selectEnvironment: true },
227+
return await withProgress(
228+
{
229+
location: ProgressLocation.Notification,
230+
title: l10n.t('Creating environment...'),
231+
},
232+
async () => {
233+
return await createAnyEnvironmentCommand(
234+
envManagers,
235+
projectManager,
236+
options ?? { selectEnvironment: true },
237+
);
238+
},
216239
);
217240
}),
218241
commands.registerCommand('python-envs.remove', async (item) => {

0 commit comments

Comments
 (0)