Skip to content
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

Don't abort early in VT reset operations if one of the steps fails #6763

Merged
2 commits merged into from
Jul 6, 2020

Conversation

j4james
Copy link
Collaborator

@j4james j4james commented Jul 2, 2020

The VT reset operations RIS and DECSTR are implemented as a series
of steps, each of which could potentially fail. Currently these
operations abort as soon as an error is detected, which is particularly
problematic in conpty mode, where some steps deliberately "fail" to
indicate that they need to be "passed through" to the conpty client. As
a result, the reset won't be fully executed. This PR changes that
behaviour, so the error state is recorded for any failures, but the
subsequent steps are still run.

Originally the structure of these operations was of the form:

bool success = DoSomething();
if (success)
{
    success = DoSomethingElse();
}

But I've now changed the code so it looks more like this:

bool success = DoSomething();
success = DoSomethingElse() && success;

This means that every one of the steps should execute, regardless of
whether previous steps were successful, but the final success state
will only be true if none of the steps has failed.

While this is only really an issue in the conhost code, I've updated
both the AdaptDispatch and TerminalDispatch classes, since I thought
it would be best to have them in sync, and in general this seems like a
better way to handle multi-step operations anyway.

VALIDATION

I've manually tested the RIS escape sequence (\ec) in the Windows
Terminal, and confirmed that it now correctly resets the cursor
position, which it wasn't doing before.

Closes #6545

@ghost ghost added Area-VT Virtual Terminal sequence support Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conpty For console issues specifically related to conpty labels Jul 2, 2020
@j4james j4james marked this pull request as ready for review July 2, 2020 17:39
@DHowett
Copy link
Member

DHowett commented Jul 3, 2020

We almost certainly need to book work to make passthrough a state decision that isn't based on whether an operation succeeded or failed 😄

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 3, 2020
@ghost
Copy link

ghost commented Jul 3, 2020

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 15 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@j4james
Copy link
Collaborator Author

j4james commented Jul 3, 2020

We almost certainly need to book work to make passthrough a state decision that isn't based on whether an operation succeeded or failed 😄

Maybe. Although I think this will eventually resolve itself once we get to implementing the passthrough mode (#1173). Because I have a hunch that the correct solution is to passthrough by default, and then have the current buffered refresh method only for special cases that can't be handled with direct VT sequences. But we're a long way from even attempting something like that.

@ghost ghost merged commit 0651fcf into microsoft:master Jul 6, 2020
@DHowett
Copy link
Member

DHowett commented Jul 6, 2020

Yeah, I think our best course forward for passthrough mode is to PT by default and take it a step further and convert APIs to emit VT wherever possible. We can keep a medium-fidelity grid/buffer representation for readback, and we can figure out what to do with APIs that address scrollback for either reading or writing, but having things be "VT-first" would go a long way...

DHowett pushed a commit that referenced this pull request Jul 7, 2020
…6763)

The VT reset operations `RIS` and `DECSTR` are implemented as a series
of steps, each of which could potentially fail. Currently these
operations abort as soon as an error is detected, which is particularly
problematic in conpty mode, where some steps deliberately "fail" to
indicate that they need to be "passed through" to the conpty client. As
a result, the reset won't be fully executed. This PR changes that
behaviour, so the error state is recorded for any failures, but the
subsequent steps are still run.

Originally the structure of these operations was of the form:

    bool success = DoSomething();
    if (success)
    {
        success = DoSomethingElse();
    }

But I've now changed the code so it looks more like this:

    bool success = DoSomething();
    success = DoSomethingElse() && success;

This means that every one of the steps should execute, regardless of
whether previous steps were successful, but the final _success_ state
will only be true if none of the steps has failed.

While this is only really an issue in the conhost code, I've updated
both the `AdaptDispatch` and `TerminalDispatch` classes, since I thought
it would be best to have them in sync, and in general this seems like a
better way to handle multi-step operations anyway.

VALIDATION

I've manually tested the `RIS` escape sequence (`\ec`) in the Windows
Terminal, and confirmed that it now correctly resets the cursor
position, which it wasn't doing before.

Closes #6545

(cherry picked from commit 0651fcf)
@j4james j4james deleted the fix-reset-passthrough branch July 7, 2020 18:59
@ghost
Copy link

ghost commented Jul 21, 2020

🎉Windows Terminal v1.1.2021.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 22, 2020

🎉Windows Terminal v1.1.2021.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 22, 2020

🎉Windows Terminal Preview v1.2.2022.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Conpty For console issues specifically related to conpty
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSH then running a reset caused blank space
3 participants