Skip to content

Commit 49677bf

Browse files
committed
Make sure PYTHON_BASIC_REPL flag is properly set, unset
1 parent 9774130 commit 49677bf

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/client/extensionActivation.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { DebuggerTypeName } from './debugger/constants';
5353
import { StopWatch } from './common/utils/stopWatch';
5454
import { registerReplCommands, registerReplExecuteOnEnter, registerStartNativeReplCommand } from './repl/replCommands';
5555
import { registerTriggerForTerminalREPL } from './terminals/codeExecution/terminalReplWatcher';
56-
import { registerBasicRepl, registerPythonStartup } from './terminals/pythonStartup';
56+
import { registerPythonStartup } from './terminals/pythonStartup';
5757
import { registerPixiFeatures } from './pythonEnvironments/common/environmentManagers/pixi';
5858
import { registerCustomTerminalLinkProvider } from './terminals/pythonStartupLinkProvider';
5959
import { registerEnvExtFeatures } from './envExt/api.internal';
@@ -184,7 +184,6 @@ async function activateLegacy(ext: ExtensionState, startupStopWatch: StopWatch):
184184
serviceManager.get<ITerminalAutoActivation>(ITerminalAutoActivation).register();
185185

186186
await registerPythonStartup(ext.context);
187-
await registerBasicRepl(ext.context);
188187

189188
serviceManager.get<ICodeExecutionManager>(ICodeExecutionManager).registerCommands();
190189

src/client/terminals/pythonStartup.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ async function applyPythonStartupSetting(context: ExtensionContext): Promise<voi
2121
const sourcePath = path.join(EXTENSION_ROOT_DIR, 'python_files', 'pythonrc.py');
2222
await copy(Uri.file(sourcePath), destPath, { overwrite: true });
2323
context.environmentVariableCollection.replace('PYTHONSTARTUP', destPath.fsPath);
24+
// When shell integration is enabled, we disable PyREPL from cpython.
25+
context.environmentVariableCollection.replace('PYTHON_BASIC_REPL', '1');
2426
} else {
2527
context.environmentVariableCollection.delete('PYTHONSTARTUP');
28+
context.environmentVariableCollection.delete('PYTHON_BASIC_REPL');
2629
}
2730
}
2831

@@ -36,8 +39,3 @@ export async function registerPythonStartup(context: ExtensionContext): Promise<
3639
}),
3740
);
3841
}
39-
40-
export async function registerBasicRepl(context: ExtensionContext): Promise<void> {
41-
// TODO: Configurable by setting
42-
context.environmentVariableCollection.replace('PYTHON_BASIC_REPL', '1');
43-
}

src/test/terminals/shellIntegration/pythonStartup.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from 'vscode';
1717
import { assert } from 'chai';
1818
import * as workspaceApis from '../../../client/common/vscodeApis/workspaceApis';
19-
import { registerBasicRepl, registerPythonStartup } from '../../../client/terminals/pythonStartup';
19+
import { registerPythonStartup } from '../../../client/terminals/pythonStartup';
2020
import { IExtensionContext } from '../../../client/common/types';
2121
import * as pythonStartupLinkProvider from '../../../client/terminals/pythonStartupLinkProvider';
2222
import { CustomTerminalLinkProvider } from '../../../client/terminals/pythonStartupLinkProvider';
@@ -135,8 +135,8 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
135135
globalEnvironmentVariableCollection.verify((c) => c.delete('PYTHONSTARTUP'), TypeMoq.Times.once());
136136
});
137137

138-
test('PYTHON_BASIC_REPL is set when registerBasicRepl is called', async () => {
139-
await registerBasicRepl(context.object);
138+
test('PYTHON_BASIC_REPL is set when shell integration is enabled', async () => {
139+
await registerPythonStartup(context.object);
140140
globalEnvironmentVariableCollection.verify(
141141
(c) => c.replace('PYTHON_BASIC_REPL', '1', TypeMoq.It.isAny()),
142142
TypeMoq.Times.once(),

0 commit comments

Comments
 (0)