@@ -7,7 +7,7 @@ import { PythonExtension, ResolvedEnvironment } from '../../api/types';
77import { IExtensionContext , Resource } from '../../common/types' ;
88import { commands , Uri , workspace } from 'vscode' ;
99import { getWorkspaceStateValue , updateWorkspaceStateValue } from '../../common/persistentState' ;
10- import { traceError } from '../../logging' ;
10+ import { traceError , traceVerbose } from '../../logging' ;
1111import { IExtensionActivationService } from '../../activation/types' ;
1212import { StopWatch } from '../../common/utils/stopWatch' ;
1313import { isParentPath } from '../../common/platform/fs-paths' ;
@@ -111,6 +111,9 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
111111 const existingJson : Record < string , string > = JSON . parse ( workspaceState ) ;
112112 const selectedEnvPath = existingJson [ workspaceUri ] ;
113113 if ( selectedEnvPath ) {
114+ traceVerbose (
115+ `Found workspace specific environment (from memento) ${ selectedEnvPath } for resource ${ resource ?. toString ( ) } ` ,
116+ ) ;
114117 return { environmentPath : selectedEnvPath , reason : 'workspaceUserSelected' } ;
115118 }
116119 } catch ( ex ) {
@@ -124,20 +127,34 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
124127 // but before this version of the extension, we did not store it in the workspace state.
125128 const workspaceEnv = await getWorkspaceSpecificVirtualEnvironment ( this . api , resource ) ;
126129 if ( workspaceEnv ) {
130+ traceVerbose (
131+ `Found workspace specific environment (from api) ${
132+ workspaceEnv . path
133+ } for resource ${ resource ?. toString ( ) } `,
134+ ) ;
127135 return { environmentPath : workspaceEnv . path , reason : 'workspaceUserSelected' } ;
128136 }
129137 }
130138
131139 const globalSelectedEnvPath = this . extensionContext . globalState . get < string | undefined > ( MEMENTO_KEY ) ;
132140 if ( globalSelectedEnvPath ) {
141+ traceVerbose (
142+ `Found global environment (from memento) ${ globalSelectedEnvPath } for resource ${ resource ?. toString ( ) } ` ,
143+ ) ;
133144 return { environmentPath : globalSelectedEnvPath , reason : 'globalUserSelected' } ;
134145 }
135- return this . api && workspace . isTrusted
136- ? {
137- environmentPath : this . api . getActiveEnvironmentPath ( resource ) . path ,
138- reason : 'defaultRecommended' ,
139- }
140- : undefined ;
146+ if ( this . api && workspace . isTrusted ) {
147+ const environmentPath = this . api . getActiveEnvironmentPath ( resource ) . path ;
148+ traceVerbose (
149+ `Found default environment (from activeEnv Path) ${ environmentPath } for resource ${ resource ?. toString ( ) } ` ,
150+ ) ;
151+ return {
152+ environmentPath,
153+ reason : 'defaultRecommended' ,
154+ } ;
155+ }
156+
157+ return undefined ;
141158 }
142159}
143160
0 commit comments