Skip to content

Commit

Permalink
Only show terminal notification for basic terminals created using '+'…
Browse files Browse the repository at this point in the history
… icon (#22275)
  • Loading branch information
Kartik Raj authored Oct 21, 2023
1 parent d758741 commit daab11d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export namespace Interpreters {
export const activatingTerminals = l10n.t('Reactivating terminals...');
export const activateTerminalDescription = l10n.t('Activated environment for');
export const terminalEnvVarCollectionPrompt = l10n.t(
'The Python extension automatically activates all terminals using the selected environment, even when the name of the environment{0} is not present in the terminal prompt. [Learn more](https://aka.ms/vscodePythonTerminalActivation).',
'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).',
);
export const terminalDeactivateProgress = l10n.t('Editing {0}...');
export const restartingTerminal = l10n.t('Restarting terminal and deactivating...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class TerminalDeactivateLimitationPrompt implements IExtensionSingleActiv
}
if (!isTestExecution()) {
// Avoid showing prompt until startup completes.
await sleep(5000);
await sleep(6000);
}
this.disposableRegistry.push(
this.appShell.onDidWriteTerminalData(async (e) => {
Expand Down
17 changes: 12 additions & 5 deletions src/client/terminals/envCollectionActivation/indicatorPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ export class TerminalIndicatorPrompt implements IExtensionSingleActivationServic
}
if (!isTestExecution()) {
// Avoid showing prompt until startup completes.
await sleep(5000);
await sleep(6000);
}
this.disposableRegistry.push(
this.terminalManager.onDidOpenTerminal(async (terminal) => {
const hideFromUser =
'hideFromUser' in terminal.creationOptions && terminal.creationOptions.hideFromUser;
const strictEnv = 'strictEnv' in terminal.creationOptions && terminal.creationOptions.strictEnv;
if (hideFromUser || strictEnv || terminal.creationOptions.name) {
// Only show this notification for basic terminals created using the '+' button.
return;
}
const cwd =
'cwd' in terminal.creationOptions && terminal.creationOptions.cwd
? terminal.creationOptions.cwd
Expand Down Expand Up @@ -78,6 +85,9 @@ export class TerminalIndicatorPrompt implements IExtensionSingleActivationServic
}
const prompts = [Common.doNotShowAgain];
const interpreter = await this.interpreterService.getActiveInterpreter(resource);
if (!interpreter) {
return;
}
const terminalPromptName = getPromptName(interpreter);
const selection = await this.appShell.showInformationMessage(
Interpreters.terminalEnvVarCollectionPrompt.format(terminalPromptName),
Expand All @@ -92,10 +102,7 @@ export class TerminalIndicatorPrompt implements IExtensionSingleActivationServic
}
}

function getPromptName(interpreter?: PythonEnvironment) {
if (!interpreter) {
return '';
}
function getPromptName(interpreter: PythonEnvironment) {
if (interpreter.envName) {
return `, ${l10n.t('i.e')} "(${interpreter.envName})"`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TensorboardExperiment } from '../../client/tensorBoard/tensorboarExperi

[true, false].forEach((tbExtensionInstalled) => {
suite(`Tensorboard Extension is ${tbExtensionInstalled ? 'installed' : 'not installed'}`, () => {
suite.only('TensorBoard nbextension code lens provider', () => {
suite('TensorBoard nbextension code lens provider', () => {
let experiment: TensorboardExperiment;
let codeLensProvider: TensorBoardNbextensionCodeLensProvider;
let cancelTokenSource: CancellationTokenSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TensorboardExperiment } from '../../client/tensorBoard/tensorboarExperi

[true, false].forEach((tbExtensionInstalled) => {
suite(`Tensorboard Extension is ${tbExtensionInstalled ? 'installed' : 'not installed'}`, () => {
suite.only('TensorBoard import code lens provider', () => {
suite('TensorBoard import code lens provider', () => {
let experiment: TensorboardExperiment;
let codeLensProvider: TensorBoardImportCodeLensProvider;
let cancelTokenSource: CancellationTokenSource;
Expand Down
2 changes: 1 addition & 1 deletion src/test/tensorBoard/tensorBoardPrompt.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Common } from '../../client/common/utils/localize';
import { TensorBoardEntrypointTrigger } from '../../client/tensorBoard/constants';
import { TensorBoardPrompt } from '../../client/tensorBoard/tensorBoardPrompt';

suite.only('TensorBoard prompt', () => {
suite('TensorBoard prompt', () => {
let applicationShell: ApplicationShell;
let commandManager: CommandManager;
let persistentState: PersistentState<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion src/test/tensorBoard/tensorBoardUsageTracker.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TensorboardExperiment } from '../../client/tensorBoard/tensorboarExperi

[true, false].forEach((tbExtensionInstalled) => {
suite(`Tensorboard Extension is ${tbExtensionInstalled ? 'installed' : 'not installed'}`, () => {
suite.only('TensorBoard usage tracker', () => {
suite('TensorBoard usage tracker', () => {
let experiment: TensorboardExperiment;
let documentManager: MockDocumentManager;
let tensorBoardImportTracker: TensorBoardUsageTracker;
Expand Down

0 comments on commit daab11d

Please sign in to comment.