Skip to content

python.execSelectionInTerminal no longer auto-executes selection (missing Enter) and doesn't open terminal if closed #251628

Open
@HistoryBeginsAtSumer

Description

@HistoryBeginsAtSumer

Type: Bug

🐞 Bug: python.execSelectionInTerminal no longer auto-executes selection or opens terminal

Describe the bug
The command python.execSelectionInTerminal, when triggered via a custom keybinding (e.g., Shift+Enter), no longer appends a newline or auto-executes the selected code in the terminal. Additionally, if no terminal is open, the command fails silently — it does not open a terminal automatically.

This breaks long-standing workflows that depend on the terminal running selected code immediately, including multi-line selections.

Note: I’m aware that Shift+Enter is not the default shortcut for this command. It’s a common custom binding among users who prefer terminal-based workflows over the Python Interactive Window or Jupyter notebooks.


Expected behavior

  • Running python.execSelectionInTerminal should:
    • Open the terminal if none is open
    • Send the selected text to the terminal
    • Press Enter (newline) so the code executes immediately

Actual behavior

  • Selected code is pasted into the terminal but not executed
  • A trailing newline is no longer sent
  • If no terminal is open, the command does nothing (no terminal is launched)

Steps to reproduce

  1. Select multiple lines of Python code (e.g., import os\nimport re)
  2. Trigger python.execSelectionInTerminal
  3. Observe:
    • Terminal opens only if already open
    • Code is pasted but ... prompt appears, waiting for Enter
    • User must manually press Enter

Environment

  • VS Code version: 1.101.0
  • Python extension version: [latest available]
  • Python version: 3.13.5
  • OS: Windows 11 Enterprise

Additional context
This behavior changed quietly in early 2025. Previously, this command auto-ran selected code, and launched the terminal if needed. It’s widely used in teaching, scripting, and exploratory workflows.

If this change is intentional, please consider adding a setting (e.g., "python.execSelectionInTerminal.appendNewline": true) to restore the previous behavior.

Thank you.

VS Code version: Code 1.101.0 (dfaf441, 2025-06-11T15:00:50.123Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 3072)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.43GB (47.35GB free)
Process Argv --crash-reporter-id 230cd7e2-c00c-4535-b5b6-4400475f0477
Screen Reader no
VM 0%
Extensions (8)
Extension Author (truncated) Version
rainbow-csv mec 3.19.0
data-workspace-vscode ms- 0.6.2
mssql ms- 1.32.1
sql-bindings-vscode ms- 0.4.1
sql-database-projects-vscode ms- 1.5.2
debugpy ms- 2025.8.0
python ms- 2025.8.0
vscode-pylance ms- 2025.6.1
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
pythonrstrctxt:31112756
nativeloc2:31192216
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
e5gg6876:31282496
pythoneinst12:31285622
bgtreat:31268568
4gafe986:31271826
c7cif404:31314491
e77a2192:31326280
pythonpulldiagcf:31325931
996jf627:31283433
pythonrdcb7:31303018
usemplatestapi:31297334
0aa6g176:31307128
7bj51361:31289155
747dc170:31275177
aj953862:31281341
generatesymbolt:31295002
convertfstringf:31295003
gendocf:31295004
pylancequickfixf:31319675
c4b42873:31327028
1292j425:31329156
b6b4d950:31327385

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions