@@ -148,6 +148,25 @@ export function buildEnvironmentApi(
148148 } )
149149 . ignoreErrors ( ) ;
150150 }
151+
152+ function getActiveEnvironmentPath ( resource ?: Resource ) {
153+ resource = resource && 'uri' in resource ? resource . uri : resource ;
154+ const jupyterEnv = resource ? jupyterPythonEnvsApi . getPythonEnvironment ( resource ) : undefined ;
155+ if ( jupyterEnv ) {
156+ traceVerbose ( 'Python Environment returned from Jupyter' , resource ?. fsPath , jupyterEnv . id ) ;
157+ return {
158+ id : jupyterEnv . id ,
159+ path : jupyterEnv . path ,
160+ } ;
161+ }
162+ const path = configService . getSettings ( resource ) . pythonPath ;
163+ const id = path === 'python' ? 'DEFAULT_PYTHON' : getEnvID ( path ) ;
164+ return {
165+ id,
166+ path,
167+ } ;
168+ }
169+
151170 disposables . push (
152171 discoveryApi . onProgress ( ( e ) => {
153172 if ( e . stage === ProgressReportStage . discoveryFinished ) {
@@ -209,7 +228,7 @@ export function buildEnvironmentApi(
209228 onEnvironmentsChanged ,
210229 onEnvironmentVariablesChanged ,
211230 jupyterPythonEnvsApi . onDidChangePythonEnvironment ( ( e ) => {
212- const jupyterEnv = environmentApi . getActiveEnvironmentPath ( e ) ;
231+ const jupyterEnv = getActiveEnvironmentPath ( e ) ;
213232 onDidActiveInterpreterChangedEvent . fire ( {
214233 id : jupyterEnv . id ,
215234 path : jupyterEnv . path ,
@@ -233,21 +252,7 @@ export function buildEnvironmentApi(
233252 } ,
234253 getActiveEnvironmentPath ( resource ?: Resource ) {
235254 sendApiTelemetry ( 'getActiveEnvironmentPath' ) ;
236- resource = resource && 'uri' in resource ? resource . uri : resource ;
237- const jupyterEnv = resource ? jupyterPythonEnvsApi . getPythonEnvironment ( resource ) : undefined ;
238- if ( jupyterEnv ) {
239- traceVerbose ( 'Python Environment returned from Jupyter' , resource ?. fsPath , jupyterEnv . id ) ;
240- return {
241- id : jupyterEnv . id ,
242- path : jupyterEnv . path ,
243- } ;
244- }
245- const path = configService . getSettings ( resource ) . pythonPath ;
246- const id = path === 'python' ? 'DEFAULT_PYTHON' : getEnvID ( path ) ;
247- return {
248- id,
249- path,
250- } ;
255+ return getActiveEnvironmentPath ( resource ) ;
251256 } ,
252257 updateActiveEnvironmentPath ( env : Environment | EnvironmentPath | string , resource ?: Resource ) : Promise < void > {
253258 sendApiTelemetry ( 'updateActiveEnvironmentPath' ) ;
0 commit comments