diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index 5d1eb52514c7..e78e7604455a 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -93,6 +93,7 @@ export namespace Common { export const alwaysIgnore = localize('Common.alwaysIgnore', 'Always Ignore'); export const ignore = localize('Common.ignore', 'Ignore'); export const selectPythonInterpreter = localize('Common.selectPythonInterpreter', 'Select Python Interpreter'); + export const changePythonInterpreter = localize('Common.changePythonInterpreter', 'Change Python Interpreter'); export const openLaunch = localize('Common.openLaunch', 'Open launch.json'); export const useCommandPrompt = localize('Common.useCommandPrompt', 'Use Command Prompt'); export const download = localize('Common.download', 'Download'); diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index c3930c5704ca..5eb63e84b9a1 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -24,6 +24,8 @@ import * as nls from 'vscode-nls'; import { showErrorMessage } from '../../../common/vscodeApis/windowApis'; import { Common } from '../../../common/utils/localize'; import { IPersistentStateFactory } from '../../../common/types'; +import { Commands } from '../../../common/constants'; +import { ICommandManager } from '../../../common/application/types'; const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -35,6 +37,7 @@ export enum debugStateKeys { @injectable() export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFactory { constructor( + @inject(ICommandManager) private readonly commandManager: ICommandManager, @inject(IInterpreterService) private readonly interpreterService: IInterpreterService, @inject(IPersistentStateFactory) private persistentState: IPersistentStateFactory, ) {} @@ -160,7 +163,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac if (notificationPromptEnabled.value) { return; } - const prompts = [Common.doNotShowAgain]; + const prompts = [Common.changePythonInterpreter, Common.doNotShowAgain]; const selection = await showErrorMessage( localize( 'deprecatedDebuggerError', @@ -172,6 +175,9 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac if (!selection) { return; } + if (selection == Common.changePythonInterpreter) { + await this.commandManager.executeCommand(Commands.Set_Interpreter); + } if (selection == Common.doNotShowAgain) { // Never show the message again await this.persistentState