-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix "Ctrl+Break can leave the WSL shell in an unusable state" #18437
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this!
I have some concerns about the overall approach - right now, it simulates the user typing in reset
any time the connection gets restarted. That may work for most connections to Linux machines, but won't work for Command Prompt, PowerShell, Yori, or some of the more esoteric things people run inside Terminal:
On Linuxen, reset
usually causes the client application to emit a hard reset (or a soft reset!) VT sequence as the output. I wonder: would it be possible or desirable to simulate that, instead?
Rather than requesting that it run the reset
command, you could output a set of control sequences that restore the terminal session to sanity.
Another approach could be to use some of the internal APIs between ControlCore
and TerminalCore
to reinitialize the terminal state to the default, rather than emitting output or input at all.
What are your thoughts?
I believe you raise a very valid concern. I'll try the approaches you have suggested. Thank you very much for your feedback! |
Hi @DHowett! I found a HardReset and SoftReset function in AdaptDispatch.cpp which looks promising. However, it is quite difficult to access the method and I need your advice on how to approach this problem. I've created a function called HardReset in terminal.cpp which attempts to access the instantiated AdaptDispatch class within OutputStateMachineEngine within StateMachine in order to call this HardReset function from AdaptDispatch.cpp. the code below outlines the nesting structure. // terminal.cpp
auto dispatch = std::make_unique<AdaptDispatch>(*this, &renderer, _renderSettings, _terminalInput);
auto engine = std::make_unique<OutputStateMachineEngine>(std::move(dispatch));
_stateMachine = std::make_unique<StateMachine>(std::move(engine)); the problem is that I thought of using
3 possible solutions to this are: 1: adding .Dispatch() to IStateMachineEngine, and adding .HardReset() to ITermDispatchI did a bit more exploring, and noticed that the 2 areas where // VtInputThread.cpp
auto dispatch = std::make_unique<InteractDispatch>();
auto engine = std::make_unique<InputStateMachineEngine>(std::move(dispatch), inheritCursor);
_pInputStateMachine = std::make_unique<StateMachine>(std::move(engine)); It thus may be useful for both engine classes (Input and Output) to be able to access dispatch via a shared Dispatch function in As for accessing the .Dispatch() method from the engine, I noticed that the only class that inherits from 2: making 2 separate
|
Summary of the Pull Request
Runs
reset
in the shell after user kills the shell withctrl + break
and pressesenter
to restart the terminal.References and Relevant Issues
18425
Detailed Description of the Pull Request / Additional comments
reset
resets the terminal state, preventing the state of the previous terminal session carrying over into the next one and hence any unintended terminal behavior such as that shown in issue 18425.Validation Steps Performed
Reproduce the bug in 18425. It should no longer occur.
PR Checklist