@@ -38,8 +38,6 @@ import { createDeferred, Deferred } from '../../common/utils/deferred';
3838import { withProgress } from '../../common/window.apis' ;
3939import { CondaStrings } from '../../common/localize' ;
4040import { showErrorMessage } from '../../common/errors/utils' ;
41- import { isWindows } from '../common/utils' ;
42- import { normalizePath } from '../../common/utils/pathUtils' ;
4341
4442export class CondaEnvManager implements EnvironmentManager , Disposable {
4543 private collection : PythonEnvironment [ ] = [ ] ;
@@ -76,16 +74,6 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
7674 this . disposablesMap . forEach ( ( d ) => d . dispose ( ) ) ;
7775 }
7876
79- private setFsPathToEnv ( fsPath : string , environment : PythonEnvironment ) : void {
80- this . fsPathToEnv . set ( isWindows ( ) ? normalizePath ( fsPath ) : fsPath , environment ) ;
81- }
82- private getFsPathToEnv ( fsPath : string ) : PythonEnvironment | undefined {
83- return this . fsPathToEnv . get ( isWindows ( ) ? normalizePath ( fsPath ) : fsPath ) ;
84- }
85- private deleteFsPathToEnv ( fsPath : string ) : void {
86- this . fsPathToEnv . delete ( isWindows ( ) ? normalizePath ( fsPath ) : fsPath ) ;
87- }
88-
8977 private _initialized : Deferred < void > | undefined ;
9078 async initialize ( ) : Promise < void > {
9179 if ( this . _initialized ) {
@@ -186,7 +174,7 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
186174 this . collection = this . collection . filter ( ( env ) => env . envId . id !== result ?. envId . id ) ;
187175 Array . from ( this . fsPathToEnv . entries ( ) )
188176 . filter ( ( [ , env ] ) => env . envId . id === result ?. envId . id )
189- . forEach ( ( [ uri ] ) => this . deleteFsPathToEnv ( uri ) ) ;
177+ . forEach ( ( [ uri ] ) => this . fsPathToEnv . delete ( uri ) ) ;
190178 this . disposablesMap . delete ( result . envId . id ) ;
191179 }
192180 } ) ,
@@ -248,13 +236,13 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
248236 async get ( scope : GetEnvironmentScope ) : Promise < PythonEnvironment | undefined > {
249237 await this . initialize ( ) ;
250238 if ( scope instanceof Uri ) {
251- let env = this . getFsPathToEnv ( scope . fsPath ) ;
239+ let env = this . fsPathToEnv . get ( scope . fsPath ) ;
252240 if ( env ) {
253241 return env ;
254242 }
255243 const project = this . api . getPythonProject ( scope ) ;
256244 if ( project ) {
257- env = this . getFsPathToEnv ( project . uri . fsPath ) ;
245+ env = this . fsPathToEnv . get ( project . uri . fsPath ) ;
258246 if ( env ) {
259247 return env ;
260248 }
@@ -272,9 +260,9 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
272260 const fsPath = folder ?. uri ?. fsPath ?? scope . fsPath ;
273261 if ( fsPath ) {
274262 if ( environment ) {
275- this . setFsPathToEnv ( fsPath , environment ) ;
263+ this . fsPathToEnv . set ( fsPath , environment ) ;
276264 } else {
277- this . deleteFsPathToEnv ( fsPath ) ;
265+ this . fsPathToEnv . delete ( fsPath ) ;
278266 }
279267 await setCondaForWorkspace ( fsPath , environment ?. environmentPath . fsPath ) ;
280268 }
@@ -290,11 +278,11 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
290278
291279 const before : Map < string , PythonEnvironment | undefined > = new Map ( ) ;
292280 projects . forEach ( ( p ) => {
293- before . set ( p . uri . fsPath , this . getFsPathToEnv ( p . uri . fsPath ) ) ;
281+ before . set ( p . uri . fsPath , this . fsPathToEnv . get ( p . uri . fsPath ) ) ;
294282 if ( environment ) {
295- this . setFsPathToEnv ( p . uri . fsPath , environment ) ;
283+ this . fsPathToEnv . set ( p . uri . fsPath , environment ) ;
296284 } else {
297- this . deleteFsPathToEnv ( p . uri . fsPath ) ;
285+ this . fsPathToEnv . delete ( p . uri . fsPath ) ;
298286 }
299287 } ) ;
300288
@@ -383,14 +371,14 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
383371 const found = this . findEnvironmentByPath ( env ) ;
384372
385373 if ( found ) {
386- this . setFsPathToEnv ( p , found ) ;
374+ this . fsPathToEnv . set ( p , found ) ;
387375 } else {
388376 // If not found, resolve the conda path. Could be portable conda.
389377 const resolved = await resolveCondaPath ( env , this . nativeFinder , this . api , this . log , this ) ;
390378
391379 if ( resolved ) {
392380 // If resolved add it to the collection
393- this . setFsPathToEnv ( p , resolved ) ;
381+ this . fsPathToEnv . set ( p , resolved ) ;
394382 this . collection . push ( resolved ) ;
395383 } else {
396384 this . log . error ( `Failed to resolve conda environment: ${ env } ` ) ;
@@ -400,7 +388,7 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
400388 // If there is not an environment already assigned by user to this project
401389 // then see if there is one in the collection
402390 if ( pathSorted . length === 1 ) {
403- this . setFsPathToEnv ( p , pathSorted [ 0 ] ) ;
391+ this . fsPathToEnv . set ( p , pathSorted [ 0 ] ) ;
404392 } else {
405393 // If there is more than one environment then we need to check if the project
406394 // is a subfolder of one of the environments
@@ -409,7 +397,7 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
409397 return t && path . normalize ( t ) === p ;
410398 } ) ;
411399 if ( found ) {
412- this . setFsPathToEnv ( p , found ) ;
400+ this . fsPathToEnv . set ( p , found ) ;
413401 }
414402 }
415403 }
@@ -418,15 +406,15 @@ export class CondaEnvManager implements EnvironmentManager, Disposable {
418406
419407 private fromEnvMap ( uri : Uri ) : PythonEnvironment | undefined {
420408 // Find environment directly using the URI mapping
421- const env = this . getFsPathToEnv ( uri . fsPath ) ;
409+ const env = this . fsPathToEnv . get ( uri . fsPath ) ;
422410 if ( env ) {
423411 return env ;
424412 }
425413
426414 // Find environment using the Python project for the Uri
427415 const project = this . api . getPythonProject ( uri ) ;
428416 if ( project ) {
429- return this . getFsPathToEnv ( project . uri . fsPath ) ;
417+ return this . fsPathToEnv . get ( project . uri . fsPath ) ;
430418 }
431419
432420 return undefined ;
0 commit comments