microsoft / microsoft/terminal

win32-input-mode: clipboard paste weird escape sequences

Open
#17,656 10 comments 0 reactions 0 assignees View on GitHub
Area-Input Issue-Bug Product-Conpty
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.21.1772.0

### Windows build number

10.0.22631.3958

### Other Software

standard ssh, Linux

### Steps to reproduce

1. Copy "test" string to clipboard
2. Run Terminal
3. Connect to Linux via SSH
4. Type `printf "\x1b[?9001h"` to enable win32-input-mode
5. Right-click on the terminal window to paste text from a clipboard

### Expected Behavior

`;4;20;116;1;0;1_;4;20;116;0;0;1_;18;101;1;0;1_;18;101;0;0;1_;3;31;115;1;0;1_;3;31;115;0;0;1_;4;20;116;1;0;1_;4;20;116;0;0;1_`

It's `t`, `e`, `s`, `t` key presses.

### Actual Behavior

`;0;27;1;0;1_;0;91;1;0;1_;0;50;1;0;1_;0;48;1;0;1_;0;48;1;0;1_;0;126;1;0;1_4;20;116;1;0;1_4;20;116;0;0;1_;18;101;1;0;1_;18;101;0;0;1_3;31;115;1;0;1_3;31;115;0;0;1_4;20;116;1;0;1_4;20;116;0;0;1_;0;27;1;0;1_;0;91;1;0;1_;0;50;1;0;1_;0;48;1;0;1_;0;49;1;0;1_;0;126;1;0;1_`

Decoded:
```
| Sequence | Vk | Sc | Uc | Kd | Cs | Rc | Description |
|-------------------|----|-----|-----|------|----|----|-----------------------|
| `;0;27;1;0;1_` | 0 | 27 | Esc | Down | 1 | 1 | Key Esc pressed |
| `;0;91;1;0;1_` | 0 | 91 | [ | Down | 1 | 1 | Key [ pressed |
| `;0;50;1;0;1_` | 0 | 50 | 2 | Down | 1 | 1 | Key 2 pressed |
| `;0;48;1;0;1_` | 0 | 48 | 0 | Down | 1 | 1 | Key 0 pressed |
| `;0;48;1;0;1_` | 0 | 48 | 0 | Down | 1 | 1 | Key 0 pressed |
| `;0;126;1;0;1_` | 0 | 126 | ~ | Down | 1 | 1 | Key ~ pressed |
| `;4;20;116;1;0;1_`| 4 | 20 | t | Down | 0 | 1 | Key t pressed |
| `;4;20;116;0;0;1_`| 4 | 20 | t | Up | 0 | 1 | Key t released |
| `;18;101;1;0;1_` | 18 | 101 | e | Down | 0 | 1 | Key e pressed |
| `;18;101;0;0;1_` | 18 | 101 | e | Up | 0 | 1 | Key e released |
| `;3;31;115;1;0;1_`| 3 | 31 | s | Down | 0 | 1 | Key s pressed |
| `;3;31;115;0;0;1_`| 3 | 31 | s | Up | 0 | 1 | Key s released |
| `;4;20;116;1;0;1_`| 4 | 20 | t | Down | 0 | 1 | Key t pressed |
| `;4;20;116;0;0;1_`| 4 | 20 | t | Up | 0 | 1 | Key t released |
| `;0;27;1;0;1_` | 0 | 27 | Esc | Down | 1 | 1 | Key Esc pressed |
| `;0;91;1;0;1_` | 0 | 91 | [ | Down | 1 | 1 | Key [ pressed |
| `;0;50;1;0;1_` | 0 | 50 | 2 | Down | 1 | 1 | Key 2 pressed |
| `;0;48;1;0;1_` | 0 | 48 | 0 | Down | 1 | 1 | Key 0 pressed |
| `;0;49;1;0;1_` | 0 | 49 | 1 | Down | 1 | 1 | Key 1 pressed |
| `;0;126;1;0;1_` | 0 | 126 | ~ | Down | 1 | 1 | Key ~ pressed |
```

As you can see, there are much more key codes. Why?

Contributor guide

Open the contributing guide

Research direction

Reproduce the report in Windows Terminal 1.21.1772.0 using the listed Windows build, SSH connection, and win32-input-mode escape sequence. Compare clipboard paste output with the decoded key events; done means paste emits only the intended text key events without the extra escape-sequence events.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.