@@ -15,25 +15,35 @@ export class ExistingProjects implements PythonProjectCreator {
1515 async create (
1616 _options ?: PythonProjectCreatorOptions ,
1717 ) : Promise < PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined > {
18- const results = await showOpenDialog ( {
19- canSelectFiles : true ,
20- canSelectFolders : true ,
21- canSelectMany : true ,
22- filters : {
23- python : [ 'py' ] ,
24- } ,
25- title : ProjectCreatorString . selectFilesOrFolders ,
26- } ) ;
18+ let existingAddUri : Uri [ ] | undefined ;
19+ if ( _options ?. rootUri ) {
20+ // If rootUri is provided, do not prompt
21+ existingAddUri = [ _options . rootUri ] ;
22+ } else if ( _options ?. quickCreate ) {
23+ // If quickCreate is true & no rootUri is provided, we should not prompt for any input
24+ throw new Error ( 'Root URI is required in quickCreate mode.' ) ;
25+ } else {
26+ // Prompt the user to select files or folders
27+ existingAddUri = await showOpenDialog ( {
28+ canSelectFiles : true ,
29+ canSelectFolders : true ,
30+ canSelectMany : true ,
31+ filters : {
32+ python : [ 'py' ] ,
33+ } ,
34+ title : ProjectCreatorString . selectFilesOrFolders ,
35+ } ) ;
36+ }
2737
28- if ( ! results || results . length === 0 ) {
38+ if ( ! existingAddUri || existingAddUri . length === 0 ) {
2939 // User cancelled the dialog & doesn't want to add any projects
3040 return ;
3141 }
3242
3343 // do we have any limitations that need to be applied here?
3444 // like selected folder not child of workspace folder?
3545
36- const filtered = results . filter ( ( uri ) => {
46+ const filtered = existingAddUri . filter ( ( uri ) => {
3747 const p = this . pm . get ( uri ) ;
3848 if ( p ) {
3949 // Skip this project if there's already a project registered with exactly the same path
0 commit comments