ConPTY modifies escape sequences passed to process input #16400

Open
opened 2026-01-31 05:06:30 +00:00 by claunia · 0 comments
Owner

Originally created by @segrey on GitHub (Jan 14, 2022).

Windows Terminal version

1.11.3471.0 (not sure Windows Terminal version matters)

Windows build number

10.0.22000.434

Other Software

No response

Steps to reproduce

Thanks for ConPTY, it's great! I'm developing a terminal emulator using ConPTY API to start a shell process and I've come across the following problem: when Ctrl+Left is pressed, ESC [ 5 D bytes are written to shell's input stream. However, shell sees it as ESC [ D. It's reproduced when cmd.exe or powershell.exe is used as a shell, but works correctly with wsl.exe. Is it a known issue?

More detailed steps to reproduce:

  1. Run forked MiniTerm app (https://github.com/segrey/terminal/tree/main/samples/ConPTY/MiniTerm). Hardcoded cmd.exe will be started.
  2. Type something in the command prompt (e.g. "aaaa bbbb") and press Ctrl+Left/Right. The cursor is moved one position instead of jumping over word.
  3. To view how shell sees written characters, comment 26th line of Program.cs and uncomment the next one. You'll need Node.js installed. Restart the app. Now pressing Ctrl+Left prints "\u001b[D" whereas "\u001b[5D" is written to the process input.
  4. If you replace writer.Write("\x001b[5D") with writer.Write("\x001b[1;5D"), Ctrl+Left works correctly, but I'd like to keep the same logic for Unix and Windows, because \x001b[5D works on Unix correctly.

Expected Behavior

The original escape sequence should be passed to shell: ESC [ 5 D

Actual Behavior

Cut escape sequence is passed to shell: ESC [ D

Originally created by @segrey on GitHub (Jan 14, 2022). ### Windows Terminal version 1.11.3471.0 (not sure Windows Terminal version matters) ### Windows build number 10.0.22000.434 ### Other Software _No response_ ### Steps to reproduce Thanks for ConPTY, it's great! I'm developing a terminal emulator using ConPTY API to start a shell process and I've come across the following problem: when Ctrl+Left is pressed, `ESC [ 5 D` bytes are written to shell's input stream. However, shell sees it as `ESC [ D`. It's reproduced when `cmd.exe` or `powershell.exe` is used as a shell, but works correctly with `wsl.exe`. Is it a known issue? More detailed steps to reproduce: 1. Run forked MiniTerm app (https://github.com/segrey/terminal/tree/main/samples/ConPTY/MiniTerm). Hardcoded `cmd.exe` will be started. 2. Type something in the command prompt (e.g. "aaaa bbbb") and press Ctrl+Left/Right. The cursor is moved one position instead of jumping over word. 3. To view how shell sees written characters, comment 26th line of Program.cs and uncomment the next one. You'll need Node.js installed. Restart the app. Now pressing Ctrl+Left prints "\u001b[D" whereas "\u001b[5D" is written to the process input. 4. If you replace [`writer.Write("\x001b[5D")`](https://github.com/segrey/terminal/blob/main/samples/ConPTY/MiniTerm/MiniTerm/Terminal.cs#L83) with `writer.Write("\x001b[1;5D")`, Ctrl+Left works correctly, but I'd like to keep the same logic for Unix and Windows, because `\x001b[5D` works on Unix correctly. ### Expected Behavior The original escape sequence should be passed to shell: `ESC [ 5 D` ### Actual Behavior Cut escape sequence is passed to shell: `ESC [ D`
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 05:06:30 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16400