diff --git a/src/client/interpreter/activation/terminalEnvVarCollectionPrompt.ts b/src/client/interpreter/activation/terminalEnvVarCollectionPrompt.ts index b5d42f0e7dbe..c8aea205a32a 100644 --- a/src/client/interpreter/activation/terminalEnvVarCollectionPrompt.ts +++ b/src/client/interpreter/activation/terminalEnvVarCollectionPrompt.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { Uri } from 'vscode'; +import { Uri, l10n } from 'vscode'; import * as path from 'path'; import { IActiveResourceService, IApplicationShell, ITerminalManager } from '../../common/application/types'; import { @@ -91,10 +91,10 @@ function getPromptName(interpreter?: PythonEnvironment) { return ''; } if (interpreter.envName) { - return ` "(${interpreter.envName})"`; + return `, ${l10n.t('i.e')} "(${interpreter.envName})"`; } if (interpreter.envPath) { - return ` "(${path.basename(interpreter.envPath)})"`; + return `, ${l10n.t('i.e')} "(${path.basename(interpreter.envPath)})"`; } return ''; } diff --git a/src/client/interpreter/activation/terminalEnvVarCollectionService.ts b/src/client/interpreter/activation/terminalEnvVarCollectionService.ts index 3849160b7e4b..fa949ff69fad 100644 --- a/src/client/interpreter/activation/terminalEnvVarCollectionService.ts +++ b/src/client/interpreter/activation/terminalEnvVarCollectionService.ts @@ -345,6 +345,10 @@ function getPromptForEnv(interpreter: PythonEnvironment | undefined) { return undefined; } if (interpreter.envName) { + if (interpreter.envName === 'base') { + // If conda base environment is selected, it can lead to "(base)" appearing twice if we return the env name. + return undefined; + } return `(${interpreter.envName}) `; } if (interpreter.envPath) { diff --git a/src/test/interpreters/activation/terminalEnvVarCollectionPrompt.unit.test.ts b/src/test/interpreters/activation/terminalEnvVarCollectionPrompt.unit.test.ts index 7bddbdcbbfe0..baa83c8b11c5 100644 --- a/src/test/interpreters/activation/terminalEnvVarCollectionPrompt.unit.test.ts +++ b/src/test/interpreters/activation/terminalEnvVarCollectionPrompt.unit.test.ts @@ -4,7 +4,7 @@ 'use strict'; import { mock, when, anything, instance, verify, reset } from 'ts-mockito'; -import { EventEmitter, Terminal, Uri } from 'vscode'; +import { EventEmitter, Terminal, Uri, l10n } from 'vscode'; import { IActiveResourceService, IApplicationShell, ITerminalManager } from '../../../client/common/application/types'; import { IConfigurationService, @@ -35,7 +35,7 @@ suite('Terminal Environment Variable Collection Prompt', () => { let interpreterService: IInterpreterService; const prompts = [Common.doNotShowAgain]; const envName = 'env'; - const expectedMessage = Interpreters.terminalEnvVarCollectionPrompt.format(` "(${envName})"`); + const expectedMessage = Interpreters.terminalEnvVarCollectionPrompt.format(`, ${l10n.t('i.e')} "(${envName})"`); setup(async () => { shell = mock(); diff --git a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts index 2e2327bd181c..b3a017031765 100644 --- a/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts +++ b/src/test/interpreters/activation/terminalEnvVarCollectionService.unit.test.ts @@ -349,6 +349,34 @@ suite('Terminal Environment Variable Collection Service', () => { expect(result).to.equal(true); }); + test('Correct track that prompt was not set for non-Windows where PS1 is not set but env name is base', async () => { + when(platform.osType).thenReturn(OSType.Linux); + const envVars: NodeJS.ProcessEnv = { CONDA_PREFIX: 'prefix/to/conda', ...process.env }; + const ps1Shell = 'zsh'; + const resource = Uri.file('a'); + const workspaceFolder: WorkspaceFolder = { + uri: Uri.file('workspacePath'), + name: 'workspace1', + index: 0, + }; + when(interpreterService.getActiveInterpreter(resource)).thenResolve(({ + type: PythonEnvType.Conda, + envName: 'base', + envPath: 'prefix/to/conda', + } as unknown) as PythonEnvironment); + when(workspaceService.getWorkspaceFolder(resource)).thenReturn(workspaceFolder); + when( + environmentActivationService.getActivatedEnvironmentVariables(resource, undefined, undefined, ps1Shell), + ).thenResolve(envVars); + when(collection.replace(anything(), anything(), anything())).thenReturn(); + + await terminalEnvVarCollectionService._applyCollection(resource, ps1Shell); + + const result = terminalEnvVarCollectionService.isTerminalPromptSetCorrectly(resource); + + expect(result).to.equal(false); + }); + test('Correct track that prompt was not set for non-Windows fish where PS1 is not set', async () => { when(platform.osType).thenReturn(OSType.Linux); const envVars: NodeJS.ProcessEnv = { CONDA_PREFIX: 'prefix/to/conda', ...process.env };