Make PyREPL disabling conditional on shell integration setting for Python 3.13+ #25281
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
PyREPL (Python's enhanced REPL introduced in Python 3.13) causes cursor indentation issues when used with VS Code's Python shell integration feature. The previous implementation unconditionally disabled PyREPL for all Python 3.13+ environments by setting
PYTHON_BASIC_REPL=1
, but this prevented users from using PyREPL even when shell integration was disabled.Solution
This PR makes PyREPL disabling conditional based on the user's shell integration preference:
PYTHON_BASIC_REPL=1
) only when:python.terminal.shellIntegration.enabled
= true) ANDBehavior Matrix
PYTHON_BASIC_REPL
not setPYTHON_BASIC_REPL
not setPYTHON_BASIC_REPL=1
PYTHON_BASIC_REPL
not set (safe fallback)Changes Made
Core Implementation
registerBasicRepl()
insrc/client/terminals/pythonStartup.ts
to conditionally set environment variable based on shell integration setting and Python versionDocumentation
package.nls.json
to inform users that PyREPL is automatically disabled when shell integration is enabled for Python 3.13+Testing
Benefits
Fixes #25240.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.