Skip to content

Commit 2794490

Browse files
Copiloteleanorjboyd
andcommitted
Add cancellation support for dependency search progress
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent 3ee2aba commit 2794490

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/managers/builtin/pipUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export async function getProjectInstallable(
178178
{
179179
location: ProgressLocation.Notification,
180180
title: VenvManagerStrings.searchingDependencies,
181+
cancellable: true,
181182
},
182183
async (_progress, token) => {
183184
const results: Uri[] = (

src/test/managers/builtin/pipUtils.unit.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,19 @@ suite('Pip Utils - getProjectInstallable', () => {
199199
assert.ok(firstResult.uri, 'Should have a URI');
200200
assert.ok(firstResult.uri.fsPath.startsWith(workspacePath), 'Should be in workspace directory');
201201
});
202+
203+
test('should show cancellable progress notification', async () => {
204+
// Arrange: Mock findFiles to return empty results
205+
findFilesStub.resolves([]);
206+
207+
// Act: Call getProjectInstallable
208+
const workspacePath = Uri.file('/test/path/root').fsPath;
209+
const projects = [{ name: 'workspace', uri: Uri.file(workspacePath) }];
210+
await getProjectInstallable(mockApi as PythonEnvironmentApi, projects);
211+
212+
// Assert: Verify withProgress was called with cancellable option
213+
assert.ok(withProgressStub.calledOnce, 'Should call withProgress once');
214+
const progressOptions = withProgressStub.firstCall.args[0] as ProgressOptions;
215+
assert.strictEqual(progressOptions.cancellable, true, 'Progress should be cancellable');
216+
});
202217
});

0 commit comments

Comments
 (0)