11import * as fse from 'fs-extra' ;
22import * as path from 'path' ;
33import * as tomljs from '@iarna/toml' ;
4- import { LogOutputChannel , ProgressLocation , QuickInputButtons , Uri } from 'vscode' ;
4+ import { LogOutputChannel , ProgressLocation , QuickInputButtons , QuickPickItem , Uri } from 'vscode' ;
55import { showQuickPickWithButtons , withProgress } from '../../common/window.apis' ;
66import { PackageManagement , Pickers , VenvManagerStrings } from '../../common/localize' ;
77import { PackageManagementOptions , PythonEnvironment , PythonEnvironmentApi , PythonProject } from '../../api' ;
@@ -10,6 +10,7 @@ import { EXTENSION_ROOT_DIR } from '../../common/constants';
1010import { selectFromCommonPackagesToInstall , selectFromInstallableToInstall } from '../common/pickers' ;
1111import { traceInfo } from '../../common/logging' ;
1212import { Installable , mergePackages } from '../common/utils' ;
13+ import { refreshPipPackages } from './utils' ;
1314
1415async function tomlParse ( fsPath : string , log ?: LogOutputChannel ) : Promise < tomljs . JsonMap > {
1516 try {
@@ -83,7 +84,7 @@ async function selectWorkspaceOrCommon(
8384 return undefined ;
8485 }
8586
86- const items = [ ] ;
87+ const items : QuickPickItem [ ] = [ ] ;
8788 if ( installable . length > 0 ) {
8889 items . push ( {
8990 label : PackageManagement . workspaceDependencies ,
@@ -102,23 +103,27 @@ async function selectWorkspaceOrCommon(
102103 items . push ( { label : PackageManagement . skipPackageInstallation } ) ;
103104 }
104105
105- const selected =
106- items . length === 1
107- ? items [ 0 ]
108- : await showQuickPickWithButtons ( items , {
109- placeHolder : Pickers . Packages . selectOption ,
110- ignoreFocusOut : true ,
111- showBackButton : true ,
112- matchOnDescription : false ,
113- matchOnDetail : false ,
114- } ) ;
106+ let showBackButton = true ;
107+ let selected : QuickPickItem [ ] | QuickPickItem | undefined = undefined ;
108+ if ( items . length === 1 ) {
109+ selected = items [ 0 ] ;
110+ showBackButton = false ;
111+ } else {
112+ selected = await showQuickPickWithButtons ( items , {
113+ placeHolder : Pickers . Packages . selectOption ,
114+ ignoreFocusOut : true ,
115+ showBackButton : true ,
116+ matchOnDescription : false ,
117+ matchOnDetail : false ,
118+ } ) ;
119+ }
115120
116121 if ( selected && ! Array . isArray ( selected ) ) {
117122 try {
118123 if ( selected . label === PackageManagement . workspaceDependencies ) {
119- return await selectFromInstallableToInstall ( installable ) ;
124+ return await selectFromInstallableToInstall ( installable , undefined , { showBackButton } ) ;
120125 } else if ( selected . label === PackageManagement . searchCommonPackages ) {
121- return await selectFromCommonPackagesToInstall ( common , installed ) ;
126+ return await selectFromCommonPackagesToInstall ( common , installed , undefined , { showBackButton } ) ;
122127 } else if ( selected . label === PackageManagement . skipPackageInstallation ) {
123128 traceInfo ( 'Package Installer: user selected skip package installation' ) ;
124129 return undefined ;
@@ -145,12 +150,13 @@ export async function getWorkspacePackagesToInstall(
145150 options : PackageManagementOptions ,
146151 project ?: PythonProject [ ] ,
147152 environment ?: PythonEnvironment ,
153+ log ?: LogOutputChannel ,
148154) : Promise < PipPackages | undefined > {
149155 const installable = ( await getProjectInstallable ( api , project ) ) ?? [ ] ;
150156 let common = await getCommonPackages ( ) ;
151157 let installed : string [ ] | undefined ;
152158 if ( environment ) {
153- installed = ( await api . getPackages ( environment ) ) ?. map ( ( pkg ) => pkg . name ) ;
159+ installed = ( await refreshPipPackages ( environment , log , { showProgress : true } ) ) ?. map ( ( pkg ) => pkg . name ) ;
154160 common = mergePackages ( common , installed ?? [ ] ) ;
155161 }
156162 return selectWorkspaceOrCommon ( installable , common , ! ! options . showSkipOption , installed ?? [ ] ) ;
@@ -167,7 +173,7 @@ export async function getProjectInstallable(
167173 const installable : Installable [ ] = [ ] ;
168174 await withProgress (
169175 {
170- location : ProgressLocation . Window ,
176+ location : ProgressLocation . Notification ,
171177 title : VenvManagerStrings . searchingDependencies ,
172178 } ,
173179 async ( _progress , token ) => {
0 commit comments