Skip to content

Commit 0f10c2f

Browse files
Copiloteleanorjboyd
andcommitted
Fix context menu "Add Python Project" command to directly add file/folder
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
1 parent 39e0675 commit 0f10c2f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/features/envCommands.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,23 @@ export async function addPythonProjectCommand(
369369
name: resource.fsPath,
370370
rootUri: resource,
371371
};
372+
373+
// When a URI is provided (right-click in explorer), directly use the existingProjects creator
374+
const existingProjectsCreator = pc.getProjectCreators().find((c) => c.name === 'existingProjects');
375+
if (existingProjectsCreator) {
376+
try {
377+
await existingProjectsCreator.create(options);
378+
return;
379+
} catch (ex) {
380+
if (ex === QuickInputButtons.Back) {
381+
return addPythonProjectCommand(resource, wm, em, pc);
382+
}
383+
throw ex;
384+
}
385+
}
372386
}
373387

388+
// If not a URI or existingProjectsCreator not found, fall back to picker
374389
const creator: PythonProjectCreator | undefined = await pickCreator(pc.getProjectCreators());
375390
if (!creator) {
376391
return;

0 commit comments

Comments
 (0)