diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/resetInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/resetInterpreter.ts index c10f90781adb..bb7283a06c64 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/resetInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/resetInterpreter.ts @@ -9,8 +9,9 @@ import { Commands } from '../../../../common/constants'; import { IConfigurationService, IPathUtils } from '../../../../common/types'; import { IPythonPathUpdaterServiceManager } from '../../types'; import { BaseInterpreterSelectorCommand } from './base'; -import { useEnvExtension } from '../../../../envExt/api.internal'; +import { shouldEnvExtHandleActivation, useEnvExtension } from '../../../../envExt/api.internal'; import { resetInterpreterLegacy } from '../../../../envExt/api.legacy'; +import { traceError } from '../../../../logging'; @injectable() export class ResetInterpreterCommand extends BaseInterpreterSelectorCommand { @@ -48,8 +49,10 @@ export class ResetInterpreterCommand extends BaseInterpreterSelectorCommand { const configTarget = targetConfig.configTarget; const wkspace = targetConfig.folderUri; await this.pythonPathUpdaterService.updatePythonPath(undefined, configTarget, 'ui', wkspace); - if (useEnvExtension()) { - await resetInterpreterLegacy(wkspace); + if (useEnvExtension() || shouldEnvExtHandleActivation()) { + await resetInterpreterLegacy(wkspace).catch((ex) => + traceError('Failed to report interpreter reset to the Python Environments extension', ex), + ); } }), ); diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts index a629d1bc793c..859d555e5675 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -45,10 +45,11 @@ import { IPythonPathUpdaterServiceManager, ISpecialQuickPickItem, } from '../../types'; -import { BaseInterpreterSelectorCommand } from './base'; import { untildify } from '../../../../common/helpers'; -import { useEnvExtension } from '../../../../envExt/api.internal'; +import { shouldEnvExtHandleActivation, useEnvExtension } from '../../../../envExt/api.internal'; +import { traceError } from '../../../../logging'; import { setInterpreterLegacy } from '../../../../envExt/api.legacy'; +import { BaseInterpreterSelectorCommand } from './base'; import { CreateEnvironmentResult } from '../../../../pythonEnvironments/creation/proposed.createEnvApis'; export type InterpreterStateArgs = { path?: string; workspace: Resource }; @@ -606,8 +607,10 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem // an empty string, in which case we should update. // Having the value `undefined` means user cancelled the quickpick, so we update nothing in that case. await this.pythonPathUpdaterService.updatePythonPath(interpreterState.path, configTarget, 'ui', wkspace); - if (useEnvExtension()) { - await setInterpreterLegacy(interpreterState.path, wkspace); + if (useEnvExtension() || shouldEnvExtHandleActivation()) { + await setInterpreterLegacy(interpreterState.path, wkspace).catch((ex) => + traceError('Failed to report newly-selected interpreter to the Python Environments extension', ex), + ); } return { path: interpreterState.path }; } diff --git a/src/client/interpreter/interpreterService.ts b/src/client/interpreter/interpreterService.ts index 54c1e0b585b8..104d7c4db10b 100644 --- a/src/client/interpreter/interpreterService.ts +++ b/src/client/interpreter/interpreterService.ts @@ -46,7 +46,7 @@ import { TriggerRefreshOptions, } from '../pythonEnvironments/base/locator'; import { sleep } from '../common/utils/async'; -import { useEnvExtension } from '../envExt/api.internal'; +import { shouldEnvExtHandleActivation, useEnvExtension } from '../envExt/api.internal'; import { getActiveInterpreterLegacy } from '../envExt/api.legacy'; type StoredPythonEnvironment = PythonEnvironment & { store?: boolean }; @@ -318,7 +318,7 @@ export class InterpreterService implements Disposable, IInterpreterService { } private async resolveActiveInterpreter(resource?: Uri): Promise { - if (useEnvExtension()) { + if (useEnvExtension() || shouldEnvExtHandleActivation()) { return getActiveInterpreterLegacy(resource); }