Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export namespace Interpreters {
'{0} environment was successfully activated, even though {1} indicator may not be present in the terminal prompt. [Learn more](https://aka.ms/vscodePythonTerminalActivation).',
);
export const shellIntegrationEnvVarCollectionDescription = l10n.t(
'Enables `python.terminal.shellIntegration.enabled` by modifying `PYTHONSTARTUP` and `PYTHON_BASIC_REPL`',
'Enables `python.terminal.shellIntegration.enabled` by modifying `PYTHONSTARTUP`',
);
export const shellIntegrationDisabledEnvVarCollectionDescription = l10n.t(
'Disables `python.terminal.shellIntegration.enabled` by unsetting `PYTHONSTARTUP` and `PYTHON_BASIC_REPL`',
Expand Down
2 changes: 0 additions & 2 deletions src/client/terminals/pythonStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ async function applyPythonStartupSetting(context: ExtensionContext): Promise<voi
const sourcePath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'pythonrc.py');
await copy(Uri.file(sourcePath), destPath, { overwrite: true });
context.environmentVariableCollection.replace('PYTHONSTARTUP', destPath.fsPath);
// When shell integration is enabled, we disable PyREPL from cpython.
context.environmentVariableCollection.replace('PYTHON_BASIC_REPL', '1');
context.environmentVariableCollection.description = new MarkdownString(
Interpreters.shellIntegrationEnvVarCollectionDescription,
);
Expand Down
16 changes: 13 additions & 3 deletions src/test/terminals/shellIntegration/pythonStartup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,25 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
globalEnvironmentVariableCollection.verify((c) => c.delete('PYTHONSTARTUP'), TypeMoq.Times.once());
});

test('PYTHON_BASIC_REPL is set when shell integration is enabled', async () => {
test('PYTHON_BASIC_REPL is not set when shell integration is enabled', async () => {
pythonConfig.setup((p) => p.get('terminal.shellIntegration.enabled')).returns(() => true);

await registerPythonStartup(context.object);

globalEnvironmentVariableCollection.verify(
(c) => c.replace('PYTHON_BASIC_REPL', '1', TypeMoq.It.isAny()),
TypeMoq.Times.once(),
(c) => c.replace('PYTHON_BASIC_REPL', TypeMoq.It.isAny(), TypeMoq.It.isAny()),
TypeMoq.Times.never(),
);
});

test('PYTHON_BASIC_REPL is deleted when shell integration is disabled', async () => {
pythonConfig.setup((p) => p.get('terminal.shellIntegration.enabled')).returns(() => false);

await registerPythonStartup(context.object);

globalEnvironmentVariableCollection.verify((c) => c.delete('PYTHON_BASIC_REPL'), TypeMoq.Times.once());
});

test('Ensure registering terminal link calls registerTerminalLinkProvider', async () => {
const registerTerminalLinkProviderStub = sinon.stub(
pythonStartupLinkProvider,
Expand Down
Loading