11import { inject , injectable } from 'inversify' ;
22import * as path from 'path' ;
33import { SemVer } from 'semver' ;
4- import { ConfigurationChangeEvent , Uri } from 'vscode' ;
5- import { IWorkspaceService } from '../../../common/application/types' ;
64import { IFileSystem , IPlatformService } from '../../../common/platform/types' ;
7- import { IDisposableRegistry } from '../../../common/types' ;
85import { cache } from '../../../common/utils/decorators' ;
96import { ICondaService } from '../../../interpreter/contracts' ;
107import { traceDecoratorVerbose } from '../../../logging' ;
@@ -17,25 +14,17 @@ import { Conda, CondaEnvironmentInfo, CondaInfo } from './conda';
1714export class CondaService implements ICondaService {
1815 private isAvailable : boolean | undefined ;
1916
20- private condaFile : Promise < string > | undefined ;
21-
2217 constructor (
2318 @inject ( IPlatformService ) private platform : IPlatformService ,
2419 @inject ( IFileSystem ) private fileSystem : IFileSystem ,
25- @inject ( IDisposableRegistry ) private disposableRegistry : IDisposableRegistry ,
26- @inject ( IWorkspaceService ) private readonly workspaceService : IWorkspaceService ,
27- ) {
28- this . addCondaPathChangedHandler ( ) ;
29- }
20+ ) { }
3021
3122 /**
3223 * Return the path to the "conda file".
3324 */
25+ // eslint-disable-next-line class-methods-use-this
3426 public async getCondaFile ( ) : Promise < string > {
35- if ( ! this . condaFile ) {
36- this . condaFile = Conda . getConda ( ) . then ( ( conda ) => conda ?. command ?? 'conda' ) ;
37- }
38- return this . condaFile ;
27+ return Conda . getConda ( ) . then ( ( conda ) => conda ?. command ?? 'conda' ) ;
3928 }
4029
4130 // eslint-disable-next-line class-methods-use-this
@@ -123,19 +112,4 @@ export class CondaService implements ICondaService {
123112 const conda = await Conda . getConda ( ) ;
124113 return conda ?. getInfo ( ) ;
125114 }
126-
127- private addCondaPathChangedHandler ( ) {
128- const disposable = this . workspaceService . onDidChangeConfiguration ( this . onDidChangeConfiguration . bind ( this ) ) ;
129- this . disposableRegistry . push ( disposable ) ;
130- }
131-
132- private async onDidChangeConfiguration ( event : ConfigurationChangeEvent ) {
133- const workspacesUris : ( Uri | undefined ) [ ] = this . workspaceService . hasWorkspaceFolders
134- ? this . workspaceService . workspaceFolders ! . map ( ( workspace ) => workspace . uri )
135- : [ undefined ] ;
136- if ( workspacesUris . findIndex ( ( uri ) => event . affectsConfiguration ( 'python.condaPath' , uri ) ) === - 1 ) {
137- return ;
138- }
139- this . condaFile = undefined ;
140- }
141115}
0 commit comments