Skip to content

Shift+Enter progressively changes indentation when running Python code in the terminal #26176

Description

Type: Bug

Summary

Regression in Python extension 2026.6.0: using Shift+Enter to run Python code from the editor in the Python terminal progressively increases indentation in multiline code.

The source code in the editor is correctly indented; the indentation is changed in the code sent to the terminal.

This workflow works correctly with Python extension 2026.4.0. Downgrading from 2026.6.0 to 2026.4.0 resolves the issue.

Minimal reproduction

Source:

plane_range = [20, 50]
n_planes = 450
valid_plane_range = (
    isinstance(plane_range, (tuple, list))
    and len(plane_range) == 2
    and all(isinstance(plane, int) for plane in plane_range)
    and all(0 <= plane < n_planes for plane in plane_range)
)

After pressing Shift+Enter, the terminal receives progressively increasing indentation:

>>> valid_plane_range = (
...     isinstance(plane_range, (tuple, list))
...         and len(plane_range) == 2
...             and all(isinstance(plane, int) for plane in plane_range)
...                 and all(0 <= plane < n_planes for plane in plane_range)
...                 )

With a larger selection, this eventually results in:

IndentationError: unexpected indent

To reproduce IndentationError: unexpected indent with a minimal larger block:

def function_test(arr=np.zeros((450, 1200, 1200, 2))):
    plane_range = [20, 50]
    n_planes = arr.shape[0]
    valid_plane_range = (
        isinstance(plane_range, (tuple, list))
        and len(plane_range) == 2
        and all(isinstance(plane, int) for plane in plane_range)
        and all(0 <= plane < n_planes for plane in plane_range)
    )
    return

Additional observation

Whenever I observe issues with sending code from the editor to the terminal after an extension update — including this issue and previous, related but not identical issues — the Python prompt itself (>>>) appears pink/violet instead of the usual neutral white in the terminal.

Expected behavior

Shift+Enter should send the selected/current Python code to the terminal without changing its indentation.

Regression

  • Working: ms-python.python 2026.4.0
  • Broken: ms-python.python 2026.6.0
  • Observed: September 30, 2026

Environment

  • OS: Windows
  • VS Code: 1.139.1
  • Python: Python 3.13.7

Extension version: 2026.6.0
VS Code version: Code 1.139.1 (04c0d99f4fb0d8afe6ce4f0c58e31e183ac3e4b1, 2026-09-25T03:40:57Z)
OS version: Windows_NT x64 10.0.26200
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.13.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

terminal
• activateEnvironment: false

Installed Extensions
Extension Name Extension Id Version
debugpy ms- 2026.6.0
js-debug ms- 1.117.0
js-debug-companion ms- 1.1.3
jsts-chat-features Typ 0.0.4
markdown-pdf yza 2.2.0
python ms- 2026.6.0
vscode-js-profile-table ms- 1.0.11
vscode-pylance ms- 2026.4.1
vscode-python-envs ms- 1.38.0
System Info
Item Value
CPUs Intel(R) Core(TM) Ultra 9 185H (22 x 3072)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x8086, DEVICE=0x7d55 [Intel(R) Arc(TM) Pro Graphics], DRIVER_VENDOR=Intel, DRIVER_VERSION=32.0.101.8860 ACTIVE
GPU1: VENDOR= 0x10de, DEVICE=0x2838 [NVIDIA RTX 3000 Ada Generation Laptop GPU], DRIVER_VERSION=32.0.15.9641
GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.9278
Machine model name:
Machine model version:
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
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.45GB (44.16GB free)
Process Argv --crash-reporter-id fb04d34d-bbc9-42e1-af06-0120fbec62ef
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
envsactivate1:31551504
cloudbuttont:31379625
3efgi100_wstrepl:31403338
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31466945
8hhj4413:31478653
cp_cls_t_1081:31454832
conptydll_true:31498968
e9c30283:31461165
46204921:31447328
ei9d7968:31496641
chat:31457767
23c7c724:31520045
ddid_t:31478206
hmra_i5g22:31518061
7df3h592:31512476
cp_cls_t_1082:31535311
logging_enabled_new:31498466
j0d79568:31499440
jb_cp_cls_t_632:31543129
56dj4588:31512888
32d76977:31512328
ha629193:31508444
jh5f2457_c:31540921
jbcp_cls_pctr_t:31531130
cp_intellij_t_nes:31548657
ahp-both-windows:31556933
ihg5j128:31534457
9gg7f176:31542112
enable_editor_pane_layout:31569726
allow-none:31555437
ac562147:31564510
c7c27ce7:31554789
1h923230:31564177
treatment-23-1:31555779
unuse_dynamic_mcp:31555281
0d8dfbc3:31570291
a1hcc538:31559322
nemo-v2:31565334
0c1h4866:31566224
session-mark-done:31591648
5b8j3302:31564601
autotiers:31584978
mangle-name-control:31572633
allow-signed-out:31592042
b17abb00-cfec-4134-90da-ee5e32ce4426:31589248
intellij_nes_preview_t:31580086
39a5d156:31574986
2bfb8b39:31585911
outline:31581109
links-control:31587703
aw-autom-on:31583758
revealsession_treatment_7ed7e840:31582194
usage_tips_endabled_0911:31587631
7g328426_fixed:31584544
codex-agent-host-stable-control:31590621
66c8a39e-e7a5-4b4c-a3c0-41b161c795c4:31586113
sessioninlinediffenabled_disabled:31587634
welcomesignin9359t:31590011
e6882f69-f5cc-4f90-9073-69a4ca3e50ea:31589215
ca19f5eb-b04f-4f52-8e6b-9f6927d4e0dc:31589210

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions