Skip to content

Commit 3c88f27

Browse files
author
Kartik Raj
authored
Improve notification texts for terminal activation (microsoft#22323)
Closes microsoft#22316
1 parent 9e07503 commit 3c88f27

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/client/common/utils/localize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ export namespace Interpreters {
197197
export const activatingTerminals = l10n.t('Reactivating terminals...');
198198
export const activateTerminalDescription = l10n.t('Activated environment for');
199199
export const terminalEnvVarCollectionPrompt = l10n.t(
200-
'The selected Python environment indicator{0} may not be present in the terminal prompt. Rest assured, all terminals are still activated. [Learn more](https://aka.ms/vscodePythonTerminalActivation).',
200+
'{0} environment was successfully activated, even though {1} may not be present in the terminal prompt. [Learn more](https://aka.ms/vscodePythonTerminalActivation).',
201201
);
202202
export const terminalDeactivateProgress = l10n.t('Editing {0}...');
203203
export const restartingTerminal = l10n.t('Restarting terminal and deactivating...');
204204
export const terminalDeactivatePrompt = l10n.t(
205-
'Deactivating virtual environments may not work by default due to a technical limitation in our activation approach, but it can be resolved by appending a line to "{0}". Be sure to restart the shell afterward. [Learn more](https://aka.ms/AAmx2ft).',
205+
'Deactivating virtual environments may not work by default. To make it work, edit your "{0}" and then restart your shell. [Learn more](https://aka.ms/AAmx2ft).',
206206
);
207207
export const activatedCondaEnvLaunch = l10n.t(
208208
'We noticed VS Code was launched from an activated conda environment, would you like to select it?',

src/client/terminals/envCollectionActivation/indicatorPrompt.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
import { inject, injectable } from 'inversify';
5-
import { Uri, l10n } from 'vscode';
5+
import { Uri } from 'vscode';
66
import * as path from 'path';
77
import { IActiveResourceService, IApplicationShell, ITerminalManager } from '../../common/application/types';
88
import {
@@ -20,6 +20,7 @@ import { PythonEnvironment } from '../../pythonEnvironments/info';
2020
import { ITerminalEnvVarCollectionService } from '../types';
2121
import { sleep } from '../../common/utils/async';
2222
import { isTestExecution } from '../../common/constants';
23+
import { PythonEnvType } from '../../pythonEnvironments/base/info';
2324

2425
export const terminalEnvCollectionPromptKey = 'TERMINAL_ENV_COLLECTION_PROMPT_KEY';
2526

@@ -85,12 +86,13 @@ export class TerminalIndicatorPrompt implements IExtensionSingleActivationServic
8586
}
8687
const prompts = [Common.doNotShowAgain];
8788
const interpreter = await this.interpreterService.getActiveInterpreter(resource);
88-
if (!interpreter) {
89+
if (!interpreter || !interpreter.type) {
8990
return;
9091
}
9192
const terminalPromptName = getPromptName(interpreter);
93+
const environmentType = interpreter.type === PythonEnvType.Conda ? 'Selected conda' : 'Python virtual';
9294
const selection = await this.appShell.showInformationMessage(
93-
Interpreters.terminalEnvVarCollectionPrompt.format(terminalPromptName),
95+
Interpreters.terminalEnvVarCollectionPrompt.format(environmentType, terminalPromptName),
9496
...prompts,
9597
);
9698
if (!selection) {
@@ -104,10 +106,10 @@ export class TerminalIndicatorPrompt implements IExtensionSingleActivationServic
104106

105107
function getPromptName(interpreter: PythonEnvironment) {
106108
if (interpreter.envName) {
107-
return `, ${l10n.t('i.e')} "(${interpreter.envName})"`;
109+
return `"(${interpreter.envName})"`;
108110
}
109111
if (interpreter.envPath) {
110-
return `, ${l10n.t('i.e')} "(${path.basename(interpreter.envPath)})"`;
112+
return `"(${path.basename(interpreter.envPath)})"`;
111113
}
112-
return '';
114+
return 'environment indicator';
113115
}

src/test/interpreters/activation/indicatorPrompt.unit.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import { mock, when, anything, instance, verify, reset } from 'ts-mockito';
7-
import { EventEmitter, Terminal, Uri, l10n } from 'vscode';
7+
import { EventEmitter, Terminal, Uri } from 'vscode';
88
import { IActiveResourceService, IApplicationShell, ITerminalManager } from '../../../client/common/application/types';
99
import {
1010
IConfigurationService,
@@ -20,8 +20,9 @@ import { sleep } from '../../core';
2020
import { IInterpreterService } from '../../../client/interpreter/contracts';
2121
import { PythonEnvironment } from '../../../client/pythonEnvironments/info';
2222
import { ITerminalEnvVarCollectionService } from '../../../client/terminals/types';
23+
import { PythonEnvType } from '../../../client/pythonEnvironments/base/info';
2324

24-
suite('Terminal Environment Variable Collection Prompt', () => {
25+
suite('Terminal Activation Indicator Prompt', () => {
2526
let shell: IApplicationShell;
2627
let terminalManager: ITerminalManager;
2728
let experimentService: IExperimentService;
@@ -35,14 +36,16 @@ suite('Terminal Environment Variable Collection Prompt', () => {
3536
let interpreterService: IInterpreterService;
3637
const prompts = [Common.doNotShowAgain];
3738
const envName = 'env';
38-
const expectedMessage = Interpreters.terminalEnvVarCollectionPrompt.format(`, ${l10n.t('i.e')} "(${envName})"`);
39+
const type = PythonEnvType.Virtual;
40+
const expectedMessage = Interpreters.terminalEnvVarCollectionPrompt.format('Python virtual', `"(${envName})"`);
3941

4042
setup(async () => {
4143
shell = mock<IApplicationShell>();
4244
terminalManager = mock<ITerminalManager>();
4345
interpreterService = mock<IInterpreterService>();
4446
when(interpreterService.getActiveInterpreter(anything())).thenResolve(({
4547
envName,
48+
type,
4649
} as unknown) as PythonEnvironment);
4750
experimentService = mock<IExperimentService>();
4851
activeResourceService = mock<IActiveResourceService>();

0 commit comments

Comments
 (0)