Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply feedback for terminal activation prompt #21905

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -91,10 +91,10 @@ function getPromptName(interpreter?: PythonEnvironment) {
return '';
}
if (interpreter.envName) {
return ` "(${interpreter.envName})"`;
return `, i.e "(${interpreter.envName})"`;
}
if (interpreter.envPath) {
return ` "(${path.basename(interpreter.envPath)})"`;
return `, i.e "(${path.basename(interpreter.envPath)})"`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should probably be localized because i.e. might not be universal across languages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch, will do that.

}
return '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(`, i.e "(${envName})"`);

setup(async () => {
shell = mock<IApplicationShell>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Loading