Ctrl+Break can leave the WSL shell in an unusable state #18425
Description
Windows Terminal version
1.22.2702.0
Windows build number
10.0.19045.5247
Other Software
VIM 8.2.4919 (inside WSL)
Steps to reproduce
- Open the Settings, and set the Profile termination behavior to Close only when process exits successfully.
- Start a WSL shell and run
vim
. - Enter
:set mouse=a
to enable mouse mode. - Press Ctrl+Break (possibly Ctrl+ScrLock depending on your keyboard).
- When you see the
press Enter to restart
message, press Enter. - Once the shell restart, try clicking in the window to select some text.
Expected Behavior
I'd expect mouse selection to work.
Actual Behavior
When you click in the window, nothing can be selected, but a bunch of "random" characters get entered at the prompt. It seems that Ctrl+Break kills the session without giving the app a chance to exit gracefully, and then when we restart the session we don't reset any of the VT state either. As a result we're left with a mouse mode enabled which the shell wasn't expecting.
This mouse mode example was just the easiest to demonstrate, but you can see how it could be even more annoying if the app had enabled something like win32 input mode, or had selected a graphic character set.
Note that for Windows console apps this is less of a problem, because they can trap the break and block it, or at least shut down more gracefully. But I don't think there is anything that Linux apps can do about this, because it's the WSL session itself that is being aborted (at least that's what appears to be happening).
Metadata
Assignees
Labels
Type
Projects
Status
To Cherry Pick