Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
);
}
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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 };
}
Expand Down
4 changes: 2 additions & 2 deletions src/client/interpreter/interpreterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -318,7 +318,7 @@ export class InterpreterService implements Disposable, IInterpreterService {
}

private async resolveActiveInterpreter(resource?: Uri): Promise<StoredPythonEnvironment | undefined> {
if (useEnvExtension()) {
if (useEnvExtension() || shouldEnvExtHandleActivation()) {
return getActiveInterpreterLegacy(resource);
}

Expand Down