microsoft / microsoft/terminal
Incorrect `DECRQM` for Win32InputMode
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 105k
- Forks
- 9.6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 29
Description
### Windows Terminal version
Commit 9b21b78feea9ff0a0b9ff2c8fa4b4aa5602d3889
### Windows build number
10.0.19045.4780
### Other Software
_No response_
### Steps to reproduce
1. Checkout and build a recent commit of Windows Terminal (I'm assuming it needs to be 450eec48de252a3a8d270bade847755ecbeb5a75 or later).
2. Open a tab with a WSL bash shell.
3. Toggle Win32 input mode with `printf "\e[?9001h"; sleep 1; printf "\e[?9001l"; read`
4. You'll likely see the keyup event for the Enter key that you just pressed.
5. Wait a second and press Enter again to return to the prompt.
6. Execute `showkey -a`
7. Try pressing Esc or Alt+[.
### Expected Behavior
You should see the VT codes for those keys like this:
```
^[ 27 0033 0x1b
^[[ 27 0033 0x1b
91 0133 0x5b
```
### Actual Behavior
Neither of those keys are picked up. And I think the problem is the heuristic we're using here:
https://github.com/microsoft/terminal/blob/9b21b78feea9ff0a0b9ff2c8fa4b4aa5602d3889/src/terminal/parser/stateMachine.cpp#L2055-L2056
That works fine if win32 input mode is always on, or always off, but when it's toggled the `_encounteredWin32InputModeSequence` flag is never reset, so that branch is always skipped.
I don't think this was an issue prior to the new VT passthrough because we never forwarded win32 input mode changes to conpty, so it should have been permanently enabled (assuming it was supported at all).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/terminal/parser/stateMachine.cpp around lines 2055-2056 and reproduce the behavior in a WSL bash tab with the provided Win32 input mode toggle. Use showkey -a after pressing Esc or Alt-[; done means those keys produce their expected VT codes after the mode is toggled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100