1- import { commands , QuickInputButtons , TaskExecution , TaskRevealKind , Terminal , Uri } from 'vscode' ;
1+ import { commands , QuickInputButtons , TaskExecution , TaskRevealKind , Terminal , Uri , workspace } from 'vscode' ;
22import {
33 CreateEnvironmentOptions ,
44 PythonEnvironment ,
@@ -20,7 +20,12 @@ import { removePythonProjectSetting, setEnvironmentManager, setPackageManager }
2020import { clipboardWriteText } from '../common/env.apis' ;
2121import { } from '../common/errors/utils' ;
2222import { pickEnvironment } from '../common/pickers/environments' ;
23- import { pickCreator , pickEnvironmentManager , pickPackageManager } from '../common/pickers/managers' ;
23+ import {
24+ pickCreator ,
25+ pickEnvironmentManager ,
26+ pickPackageManager ,
27+ pickWorkspaceFolder ,
28+ } from '../common/pickers/managers' ;
2429import { pickProject , pickProjectMany } from '../common/pickers/projects' ;
2530import { activeTextEditor , showErrorMessage , showInformationMessage } from '../common/window.apis' ;
2631import { quoteArgs } from './execution/execUtils' ;
@@ -451,6 +456,20 @@ export async function addPythonProjectCommand(
451456 return ;
452457 }
453458
459+ // if multiroot, prompt the user to select which workspace to create the project in
460+ const workspaceFolders = workspace . workspaceFolders ;
461+ if ( ! resource && workspaceFolders && workspaceFolders . length > 1 ) {
462+ try {
463+ const workspace = await pickWorkspaceFolder ( true ) ;
464+ resource = workspace ?. uri ;
465+ } catch ( ex ) {
466+ if ( ex === QuickInputButtons . Back ) {
467+ return addPythonProjectCommand ( resource , wm , em , pc ) ;
468+ }
469+ throw ex ;
470+ }
471+ }
472+
454473 try {
455474 await creator . create ( options ) ;
456475 } catch ( ex ) {
0 commit comments