11import  *  as  os  from  'os' ; 
22import  *  as  vscode  from  'vscode' ; 
3- import  {  commands ,   ConfigurationTarget ,   Disposable ,   OutputChannel ,   Terminal ,  Uri ,  window ,  workspace  }  from  'vscode' ; 
3+ import  {  ConfigurationTarget ,  Uri ,  window ,  workspace  }  from  'vscode' ; 
44import  *  as  settings  from  './configSettings' ; 
55import  {  isNotInstalledError  }  from  './helpers' ; 
6- import  {  error  }  from  './logger' ; 
76import  {  execPythonFile ,  getFullyQualifiedPythonInterpreterPath ,  IS_WINDOWS  }  from  './utils' ; 
87
98export  enum  Product  { 
@@ -203,12 +202,13 @@ export class Installer implements vscode.Disposable {
203202 return  InstallerResponse . Ignore ; 
204203 } 
205204
206-  const  installOption  =  ProductInstallationPrompt . has ( product )  ? ProductInstallationPrompt . get ( product )  : `Install ${ productName }  ; 
205+  // tslint:disable-next-line:no-non-null-assertion 
206+  const  installOption  =  ProductInstallationPrompt . has ( product )  ? ProductInstallationPrompt . get ( product ) !  : `Install ${ productName }  ; 
207207 const  disableOption  =  `Disable ${ productTypeName }  ; 
208208 const  dontShowAgain  =  'Don\'t show this prompt again' ; 
209209 const  alternateFormatter  =  product  ===  Product . autopep8  ? 'yapf'  : 'autopep8' ; 
210210 const  useOtherFormatter  =  `Use '${ alternateFormatter }  ; 
211-  const  options  =  [ ] ; 
211+  const  options :  string [ ]  =  [ ] ; 
212212 options . push ( installOption ) ; 
213213 if  ( productType  ===  ProductType . Formatter )  { 
214214 options . push ( ...[ useOtherFormatter ] ) ; 
@@ -217,6 +217,9 @@ export class Installer implements vscode.Disposable {
217217 options . push ( ...[ disableOption ,  dontShowAgain ] ) ; 
218218 } 
219219 const  item  =  await  window . showErrorMessage ( `${ productTypeName } ${ productName }  ,  ...options ) ; 
220+  if  ( ! item )  { 
221+  return  InstallerResponse . Ignore ; 
222+  } 
220223 switch  ( item )  { 
221224 case  installOption : { 
222225 return  this . install ( product ,  resource ) ; 
@@ -313,26 +316,28 @@ export class Installer implements vscode.Disposable {
313316 } 
314317
315318 return  installationPromise 
316-  . then ( ( )  =>  this . isInstalled ( product ) ) 
319+  . then ( async   ( )  =>  this . isInstalled ( product ) ) 
317320 . then ( isInstalled  =>  isInstalled  ? InstallerResponse . Installed  : InstallerResponse . Ignore ) ; 
318321 } 
319322
320323 // tslint:disable-next-line:member-ordering 
321-  public  isInstalled ( product : Product ,  resource ?: Uri ) : Promise < boolean  |  undefined >  { 
324+  public  async   isInstalled ( product : Product ,  resource ?: Uri ) : Promise < boolean  |  undefined >  { 
322325 return  isProductInstalled ( product ,  resource ) ; 
323326 } 
324327
325328 // tslint:disable-next-line:member-ordering no-any 
326-  public  uninstall ( product : Product ,  resource ?: Uri ) : Promise < any >  { 
329+  public  async   uninstall ( product : Product ,  resource ?: Uri ) : Promise < any >  { 
327330 return  uninstallproduct ( product ,  resource ) ; 
328331 } 
329332 // tslint:disable-next-line:member-ordering 
330-  public  disableLinter ( product : Product ,  resource : Uri )  { 
331-  if  ( resource  &&  ! workspace . getWorkspaceFolder ( resource ) )  { 
333+  public  async   disableLinter ( product : Product ,  resource ? : Uri )  { 
334+  if  ( resource  &&  workspace . getWorkspaceFolder ( resource ) )  { 
332335 // tslint:disable-next-line:no-non-null-assertion 
333336 const  settingToDisable  =  SettingToDisableProduct . get ( product ) ! ; 
334337 const  pythonConfig  =  workspace . getConfiguration ( 'python' ,  resource ) ; 
335-  return  pythonConfig . update ( settingToDisable ,  false ,  ConfigurationTarget . Workspace ) ; 
338+  const  isMultiroot  =  Array . isArray ( workspace . workspaceFolders )  &&  workspace . workspaceFolders . length  >  1 ; 
339+  const  configTarget  =  isMultiroot  ? ConfigurationTarget . WorkspaceFolder  : ConfigurationTarget . Workspace ; 
340+  return  pythonConfig . update ( settingToDisable ,  false ,  configTarget ) ; 
336341 }  else  { 
337342 const  pythonConfig  =  workspace . getConfiguration ( 'python' ) ; 
338343 return  pythonConfig . update ( 'linting.enabledWithoutWorkspace' ,  false ,  true ) ; 
@@ -382,7 +387,7 @@ async function isProductInstalled(product: Product, resource?: Uri): Promise<boo
382387} 
383388
384389// tslint:disable-next-line:no-any 
385- function  uninstallproduct ( product : Product ,  resource ?: Uri ) : Promise < any >  { 
390+ async   function  uninstallproduct ( product : Product ,  resource ?: Uri ) : Promise < any >  { 
386391 if  ( ! ProductUninstallScripts . has ( product ) )  { 
387392 return  Promise . resolve ( ) ; 
388393 } 
0 commit comments