microsoft / microsoft/vscode

Terminal no longer responds to escape sequence 6n

Open
#336,945 0 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

terminal
Dominant language
TypeScript
Stars
193k
Forks
42.8k
PR merge metrics
PR metrics pending

Description

Type: Bug

On Windows, the terminal no longer correctly responds to escape sequence 6n with the current cursor position.

To reproduce, open a terminal (does not appear to matter what shell is used, but I tested on PowerShell 7.6.6 and Git Bash) and run python. In the Python shell, run

from contextlib import contextmanager
from ctypes import byref, windll, wintypes
import sys

@contextmanager
def disable_echo():
    stdin_handle = windll.kernel32.GetStdHandle(-10)
    old_stdin_mode = wintypes.DWORD()
    windll.kernel32.GetConsoleMode(stdin_handle, byref(old_stdin_mode))
    try:
        windll.kernel32.SetConsoleMode(stdin_handle, 0)
        yield
    finally:
        windll.kernel32.SetConsoleMode(stdin_handle, old_stdin_mode)

def get_cursor_pos() -> tuple[int, int]:
    with disable_echo():
        sys.stdout.write("\x1b[6n")
        sys.stdout.flush()
        result = ""
        while not result.endswith("R"):
            result += sys.stdin.read(1)
        row, _, col = result.removeprefix("\x1b[").removesuffix("R").partition(";")
        return (int(col) - 1, int(row) - 1)

get_cursor_pos()

This hangs inside the sys.stdin.read(1) call. If the same thing is run in Windows Terminal, it correctly returns a value such as

>>> get_cursor_pos()
(0, 29)

Checking the stdout mode on both VS Code's terminal and Windows terminal...

stdout_handle = windll.kernel32.GetStdHandle(-11)
stdout_mode = wintypes.DWORD()
windll.kernel32.GetConsoleMode(stdout_handle, byref(stdout_mode))
stdout_mode.value

...results in 7, which includes the 0x4 bit for ENABLE_VIRTUAL_TERMINAL_PROCESSING, so I would expect it to work in both. I previously tested a project which uses this code in VS Code's terminal, so I know this used to work in an earlier version of VS Code, but I don't know which version that was.

VS Code version: Code 1.138.0 (7debcd0e2acdea1c52de81bf9ee1620444407dda, 2026-09-15T07:24:32Z)
OS version: Windows_NT x64 10.0.26200
Modes:

System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i5-13600K (20 x 3494)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x10de, DEVICE=0x2705 [NVIDIA GeForce RTX 4070 Ti SUPER], DRIVER_VENDOR=NVIDIA, DRIVER_VERSION=32.0.16.1692 ACTIVE
GPU1: 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.75GB (37.00GB free)
Process Argv --folder-uri file:///c%3A/Users/Joel/source/repos/zmk-cli --crash-reporter-id 5f69b14c-e8ee-4ca7-bfac-8fb13e9f9407
Screen Reader no
VM 0%
Extensions (71)
Name Identifier Author Version
TypeScript + Webpack Problem Matchers amodio.tsl-problem-matcher amodio 0.6.2
Color Picker anseki.vscode-color anseki 0.4.5
OpenSCAD antyos.openscad Antyos 1.3.2
Language MaxScript atelierbump.language-maxscript atelierbump 3.0.2
React Compiler Marker ✨ blazejkustra.react-compiler-marker blazejkustra 2.3.0
Ruff charliermarsh.ruff charliermarsh 2026.82.0
Doxygen Documentation Generator cschlosser.doxdocgen cschlosser 1.4.0
Arm Assembly dan-c-underwood.arm dan-c-underwood 1.7.4
ESLint dbaeumer.vscode-eslint dbaeumer 3.0.34
GitLens — Git supercharged eamodio.gitlens eamodio 19.2.0
EditorConfig editorconfig.editorconfig EditorConfig 0.18.2
Prettier - Code formatter esbenp.prettier-vscode esbenp 12.4.0
GitHub Repositories github.remotehub GitHub 0.64.0
GitHub Actions github.vscode-github-actions github 0.32.3
Spreadsheet Viewer grapecity.gc-excelviewer GrapeCity 4.2.66
NuGet Package Manager jmrog.vscode-nuget-package-manager jmrog 1.1.6
CircuitPython joedevivo.vscode-circuitpython joedevivo 0.2.0
vscode-tree-sitter-query jrieken.vscode-tree-sitter-query jrieken 0.0.6
OpenSCAD Formatter juliangmp.openscad-formatter JulianGmp 1.2.1
Intel HEX format keroc.hex-fmt keroc 1.0.0
Devicetree LSP kylemicallefbonnici.dts-lsp KyleMicallefBonnici 0.13.0
Rainbow CSV mechatroner.rainbow-csv mechatroner 3.24.1
JSON5 syntax mrmlnc.vscode-json5 mrmlnc 1.0.0
Container Tools ms-azuretools.vscode-containers ms-azuretools 2.5.1
C# ms-dotnettools.csharp ms-dotnettools 2.160.4
.NET Install Tool ms-dotnettools.vscode-dotnet-runtime ms-dotnettools 3.1.0
Python Debugger ms-python.debugpy ms-python 2026.6.0
Python ms-python.python ms-python 2026.4.0
Pylance ms-python.vscode-pylance ms-python 2026.3.1
Python Environments ms-python.vscode-python-envs ms-python 1.36.0
Jupyter ms-toolsai.jupyter ms-toolsai 2025.9.1
Jupyter Keymap ms-toolsai.jupyter-keymap ms-toolsai 1.1.2
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers ms-toolsai 1.3.0
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags ms-toolsai 0.1.9
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow ms-toolsai 0.1.6
Dev Containers ms-vscode-remote.remote-containers ms-vscode-remote 0.469.0
Remote - SSH ms-vscode-remote.remote-ssh ms-vscode-remote 0.128.0
Remote - SSH: Editing Configuration Files ms-vscode-remote.remote-ssh-edit ms-vscode-remote 0.87.0
WSL ms-vscode-remote.remote-wsl ms-vscode-remote 0.104.3
Azure Repos ms-vscode.azure-repos ms-vscode 0.40.0
C/C++ DevTools ms-vscode.cpp-devtools ms-vscode 0.6.18
C/C++ ms-vscode.cpptools ms-vscode 1.34.4
Hex Editor ms-vscode.hexeditor ms-vscode 1.11.1
PowerShell ms-vscode.powershell ms-vscode 2025.4.0
Remote Explorer ms-vscode.remote-explorer ms-vscode 0.5.0
Remote Repositories ms-vscode.remote-repositories ms-vscode 0.42.0
Serial Monitor ms-vscode.vscode-serial-monitor ms-vscode 0.13.1
Gulp Tasks nickdodd79.gulptasks nickdodd79 1.3.1
nRF Connect for VS Code nordic-semiconductor.nrf-connect nordic-semiconductor 2026.9.2797
nRF DeviceTree nordic-semiconductor.nrf-devicetree nordic-semiconductor 2026.9.977
nRF Kconfig nordic-semiconductor.nrf-kconfig nordic-semiconductor 2026.9.356
nRF Terminal nordic-semiconductor.nrf-terminal nordic-semiconductor 2026.9.409
Vetur octref.vetur octref 0.37.3
DeviceTree plorefice.devicetree plorefice 0.1.1
XML redhat.vscode-xml redhat 0.29.3
YAML redhat.vscode-yaml redhat 1.24.0
rust-analyzer rust-lang.rust-analyzer rust-lang 0.3.3049
Svg Preview simonsiefke.svg-preview SimonSiefke 2.8.3
Config Defaults spadin.config-defaults spadin 1.3.0
Memento Inputs spadin.memento-inputs spadin 1.0.0
ZMK Tools spadin.zmk-tools spadin 1.5.0
ninja-build surajbarkale.ninja surajbarkale 0.0.1
Tombi tombi-toml.tombi tombi-toml 0.9.5
Mako tommorris.mako tommorris 0.2.0
vscode-pdf tomoki1207.pdf tomoki1207 1.2.2
GNU Linker Map files trond-snekvik.gnu-mapfiles trond-snekvik 1.1.0
MDX unifiedjs.vscode-mdx unifiedjs 1.8.18
CodeLLDB vadimcn.vscode-lldb vadimcn 1.12.1
Vitest vitest.explorer vitest 1.52.0
vscode-icons vscode-icons-team.vscode-icons vscode-icons-team 12.19.0
LinkerScript zixuanwang.linkerscript ZixuanWang 1.0.4
A/B Experiments
vsliv368cf:30146710
pythonvspyt551cf:31249601
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
82j33506:31327384
envsactivate1:31551504
cloudbuttont:31379625
3efgi100_wstrepl:31403338
ddidt:31399633
ec5jj548:31422691
cp_cls_t_966_ss:31526232
4je02754:31466945
8hhj4413:31478653
cp_cls_c_1081:31454833
conptydll_true:31498968
e9c30283:31461165
c9b86496:31447327
ei9d7968:31496641
chat:31457767
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
a1ije391_t:31540920
jbcp_cls_pctr_t:31531130
cp_intellij_t_nes:31548657
gf14b233:31526830
ahp-both-windows:31556933
ihg5j128:31534457
9gg7f176:31542112
enable_editor_pane_layout:31569726
allow-none:31555437
36h42362:31564511
c7c27ce7:31554789
1h923230:31564177
treatment-23-1:31555779
unuse_dynamic_mcp:31555281
0d8dfbc3:31570291
a1hcc538:31559322
0c1h4866:31566224
session-archive:31558132
5b8j3302:31564601
autotiers:31584978
mangle-name-control:31572633
allow-signed-out:31584137
intellij_nes_preview_t:31580086
39a5d156:31574986
2bfb8b39:31585911
outline:31581109
links-control:31586637
aw-autom-on:31583758
revealsession_control_7ed7e840:31582193
4ab0b639:31584543
codex-agent-host-stable-control:31585316
66c8a39e-e7a5-4b4c-a3c0-41b161c795c4:31586113
permission_prompt_treatment:1332566
ccr_pr_nudge_control:1319470
vsc_wsm_c:1340633
1g5a5742:1379227
3aced641:1389836

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python reproduction in VS Code's integrated terminal with PowerShell 7.6.6 and Git Bash, then compare the response with Windows Terminal. Trace the integrated terminal's Windows escape-sequence and console input handling. Done means escape sequence 6n returns the cursor position without hanging in sys.stdin.read(1).

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.