File tree Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Expand file tree Collapse file tree 3 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -707,16 +707,20 @@ export interface PythonProjectCreator {
707
707
readonly iconPath ?: IconPath ;
708
708
709
709
/**
710
- * A flag indicating whether the project creator supports quick create where no user input is required.
710
+ * Creates a new Python project(s) or, if files are not a project, returns Uri(s) to the created files.
711
+ * Anything that needs its own python environment constitutes a project.
712
+ * @param options Optional parameters for creating the Python project.
713
+ * @returns A promise that resolves to one of the following:
714
+ * - PythonProject or PythonProject[]: when a single or multiple projects are created.
715
+ * - Uri or Uri[]: when files are created that do not constitute a project.
716
+ * - undefined: if project creation fails.
711
717
*/
712
- readonly supportsQuickCreate ?: boolean ;
718
+ create ( options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined > ;
713
719
714
720
/**
715
- * Creates a new Python project or projects.
716
- * @param options - Optional parameters for creating the Python project.
717
- * @returns A promise that resolves to a Python project, an array of Python projects, or undefined.
721
+ * A flag indicating whether the project creator supports quick create where no user input is required.
718
722
*/
719
- create ( options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | undefined > ;
723
+ readonly supportsQuickCreate ?: boolean ;
720
724
}
721
725
722
726
/**
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ export class ExistingProjects implements PythonProjectCreator {
13
13
14
14
constructor ( private readonly pm : PythonProjectManager ) { }
15
15
16
- async create ( _options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | undefined > {
16
+ async create (
17
+ _options ?: PythonProjectCreatorOptions ,
18
+ ) : Promise < PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined > {
17
19
const results = await showOpenDialog ( {
18
20
canSelectFiles : true ,
19
21
canSelectFolders : true ,
Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ export async function addPythonProject(
368
368
return ;
369
369
}
370
370
371
- let results : PythonProject | PythonProject [ ] | undefined ;
371
+ let results : PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined ;
372
372
try {
373
373
results = await creator . create ( ) ;
374
374
if ( results === undefined ) {
@@ -381,6 +381,15 @@ export async function addPythonProject(
381
381
throw ex ;
382
382
}
383
383
384
+ if (
385
+ results instanceof Uri ||
386
+ ( Array . isArray ( results ) && results . length > 0 && results . every ( ( r ) => r instanceof Uri ) )
387
+ ) {
388
+ // the results are Uris, which means they aren't projects and shouldn't be added
389
+ return ;
390
+ }
391
+ results = results as PythonProject | PythonProject [ ] ;
392
+
384
393
if ( ! Array . isArray ( results ) ) {
385
394
results = [ results ] ;
386
395
}
You can’t perform that action at this time.
0 commit comments