@@ -8,6 +8,7 @@ import { PythonEnvironmentApi, PythonProject } from '../../api';
88import { findFiles } from '../../common/workspace.apis' ;
99import { EXTENSION_ROOT_DIR } from '../../common/constants' ;
1010import { Installable , selectFromCommonPackagesToInstall , selectFromInstallableToInstall } from '../common/pickers' ;
11+ import { traceInfo } from '../../common/logging' ;
1112
1213async function tomlParse ( fsPath : string , log ?: LogOutputChannel ) : Promise < tomljs . JsonMap > {
1314 try {
@@ -75,47 +76,56 @@ async function selectWorkspaceOrCommon(
7576 installable : Installable [ ] ,
7677 common : Installable [ ] ,
7778) : Promise < string [ ] | undefined > {
78- if ( installable . length > 0 ) {
79- const selected = await showQuickPickWithButtons (
80- [
81- {
82- label : PackageManagement . workspaceDependencies ,
83- description : PackageManagement . workspaceDependenciesDescription ,
84- } ,
85- {
86- label : PackageManagement . commonPackages ,
87- description : PackageManagement . commonPackagesDescription ,
88- } ,
89- ] ,
90- {
91- placeHolder : Pickers . Packages . selectOption ,
92- ignoreFocusOut : true ,
93- showBackButton : true ,
94- matchOnDescription : false ,
95- matchOnDetail : false ,
96- } ,
97- ) ;
98- if ( selected && ! Array . isArray ( selected ) ) {
99- try {
100- if ( selected . label === PackageManagement . workspaceDependencies ) {
101- return await selectFromInstallableToInstall ( installable ) ;
102- } else if ( selected . label === PackageManagement . commonPackages ) {
103- return await selectFromCommonPackagesToInstall ( common ) ;
104- }
105- // eslint-disable-next-line @typescript-eslint/no-explicit-any
106- } catch ( ex : any ) {
107- if ( ex === QuickInputButtons . Back ) {
108- return selectWorkspaceOrCommon ( installable , common ) ;
109- }
110- }
111- }
79+ if ( installable . length === 0 && common . length === 0 ) {
11280 return undefined ;
11381 }
11482
83+ const items = [ ] ;
84+ if ( installable . length > 0 ) {
85+ items . push ( {
86+ label : PackageManagement . workspaceDependencies ,
87+ description : PackageManagement . workspaceDependenciesDescription ,
88+ } ) ;
89+ }
90+
11591 if ( common . length > 0 ) {
116- return selectFromCommonPackagesToInstall ( common ) ;
92+ items . push ( {
93+ label : PackageManagement . commonPackages ,
94+ description : PackageManagement . commonPackagesDescription ,
95+ } ) ;
11796 }
11897
98+ if ( items . length > 0 ) {
99+ items . push ( { label : PackageManagement . skipPackageInstallation } ) ;
100+ } else {
101+ return undefined ;
102+ }
103+
104+ const selected = await showQuickPickWithButtons ( items , {
105+ placeHolder : Pickers . Packages . selectOption ,
106+ ignoreFocusOut : true ,
107+ showBackButton : true ,
108+ matchOnDescription : false ,
109+ matchOnDetail : false ,
110+ } ) ;
111+
112+ if ( selected && ! Array . isArray ( selected ) ) {
113+ try {
114+ if ( selected . label === PackageManagement . workspaceDependencies ) {
115+ return await selectFromInstallableToInstall ( installable ) ;
116+ } else if ( selected . label === PackageManagement . commonPackages ) {
117+ return await selectFromCommonPackagesToInstall ( common ) ;
118+ } else {
119+ traceInfo ( 'Package Installer: user selected skip package installation' ) ;
120+ return undefined ;
121+ }
122+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
123+ } catch ( ex : any ) {
124+ if ( ex === QuickInputButtons . Back ) {
125+ return selectWorkspaceOrCommon ( installable , common ) ;
126+ }
127+ }
128+ }
119129 return undefined ;
120130}
121131
0 commit comments