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 {
707707 readonly iconPath ?: IconPath ;
708708
709709 /**
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.
711717 */
712- readonly supportsQuickCreate ?: boolean ;
718+ create ( options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined > ;
713719
714720 /**
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.
718722 */
719- create ( options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | undefined > ;
723+ readonly supportsQuickCreate ?: boolean ;
720724}
721725
722726/**
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ export class ExistingProjects implements PythonProjectCreator {
1313
1414 constructor ( private readonly pm : PythonProjectManager ) { }
1515
16- async create ( _options ?: PythonProjectCreatorOptions ) : Promise < PythonProject | PythonProject [ ] | undefined > {
16+ async create (
17+ _options ?: PythonProjectCreatorOptions ,
18+ ) : Promise < PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined > {
1719 const results = await showOpenDialog ( {
1820 canSelectFiles : true ,
1921 canSelectFolders : true ,
Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ export async function addPythonProject(
368368 return ;
369369 }
370370
371- let results : PythonProject | PythonProject [ ] | undefined ;
371+ let results : PythonProject | PythonProject [ ] | Uri | Uri [ ] | undefined ;
372372 try {
373373 results = await creator . create ( ) ;
374374 if ( results === undefined ) {
@@ -381,6 +381,15 @@ export async function addPythonProject(
381381 throw ex ;
382382 }
383383
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+
384393 if ( ! Array . isArray ( results ) ) {
385394 results = [ results ] ;
386395 }
You can’t perform that action at this time.
0 commit comments