@@ -7,7 +7,7 @@ import { PythonExtension, ResolvedEnvironment } from '../../api/types';
7
7
import { IExtensionContext , Resource } from '../../common/types' ;
8
8
import { commands , Uri , workspace } from 'vscode' ;
9
9
import { getWorkspaceStateValue , updateWorkspaceStateValue } from '../../common/persistentState' ;
10
- import { traceError } from '../../logging' ;
10
+ import { traceError , traceVerbose } from '../../logging' ;
11
11
import { IExtensionActivationService } from '../../activation/types' ;
12
12
import { StopWatch } from '../../common/utils/stopWatch' ;
13
13
import { isParentPath } from '../../common/platform/fs-paths' ;
@@ -111,6 +111,9 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
111
111
const existingJson : Record < string , string > = JSON . parse ( workspaceState ) ;
112
112
const selectedEnvPath = existingJson [ workspaceUri ] ;
113
113
if ( selectedEnvPath ) {
114
+ traceVerbose (
115
+ `Found workspace specific environment (from memento) ${ selectedEnvPath } for resource ${ resource ?. toString ( ) } ` ,
116
+ ) ;
114
117
return { environmentPath : selectedEnvPath , reason : 'workspaceUserSelected' } ;
115
118
}
116
119
} catch ( ex ) {
@@ -124,20 +127,34 @@ export class RecommendedEnvironmentService implements IRecommendedEnvironmentSer
124
127
// but before this version of the extension, we did not store it in the workspace state.
125
128
const workspaceEnv = await getWorkspaceSpecificVirtualEnvironment ( this . api , resource ) ;
126
129
if ( workspaceEnv ) {
130
+ traceVerbose (
131
+ `Found workspace specific environment (from api) ${
132
+ workspaceEnv . path
133
+ } for resource ${ resource ?. toString ( ) } `,
134
+ ) ;
127
135
return { environmentPath : workspaceEnv . path , reason : 'workspaceUserSelected' } ;
128
136
}
129
137
}
130
138
131
139
const globalSelectedEnvPath = this . extensionContext . globalState . get < string | undefined > ( MEMENTO_KEY ) ;
132
140
if ( globalSelectedEnvPath ) {
141
+ traceVerbose (
142
+ `Found global environment (from memento) ${ globalSelectedEnvPath } for resource ${ resource ?. toString ( ) } ` ,
143
+ ) ;
133
144
return { environmentPath : globalSelectedEnvPath , reason : 'globalUserSelected' } ;
134
145
}
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 ;
141
158
}
142
159
}
143
160
0 commit comments