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

Avoid encoding VT via win32 input mode #16407

Merged
merged 2 commits into from
Dec 4, 2023
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Dec 1, 2023

This changeset avoids re-encoding output from AdaptDispatch
via the win32-input-mode mechanism when VT input is enabled.
That is, an AdaptDispatch output like \x1b[C would otherwise
result in dozens of characters of input.

Related to #16343

Validation Steps Performed

  • Replace conhost with this
  • Launch a Win32 application inside WSL
  • ASCII keyboard inputs are represented as single INPUT_RECORDs ✅

@lhecker lhecker added Product-Conpty For console issues specifically related to conpty Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) zInbox-Bug Ignore me! labels Dec 1, 2023
@DHowett
Copy link
Member

DHowett commented Dec 2, 2023

There's another bug for this as well. Mouse mode one.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, it doesn't fix the mouse mode one. But it's a good start!

@@ -602,6 +602,30 @@ size_t InputBuffer::Write(const std::span<const INPUT_RECORD>& inEvents)
}
}

void InputBuffer::WriteDirect(const std::span<const INPUT_RECORD>& inEvents)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new method for this, couldn't you just make the existing _HandleTerminalInputCallback method public, and call it with a string instead of an event list? That way you could drop all that event generation code from the ReturnResponse method, and pass the string through directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good point. I'll make that change.

ServiceLocator::LocateGlobals().hInputEvent.SetEvent();
}

WakeUpReadersWaitingForData();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_HandleTerminalInputCallback doesn't wake up readers if there were no bits - should we do that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit afraid of outright using _HandleTerminalInputCallback, because InputBuffer::Write actually does it exactly like that: It always calls WakeUpReadersWaitingForData(). In the future, if I ever get to rewrite InputBuffer with proper string support, I was hoping to really understand how this works and to properly unify the event/wakeup code.

@DHowett DHowett merged commit 0da37a1 into main Dec 4, 2023
15 of 17 checks passed
@DHowett DHowett deleted the dev/lhecker/win32-double-encoding branch December 4, 2023 23:05
DHowett pushed a commit that referenced this pull request Dec 4, 2023
This changeset avoids re-encoding output from `AdaptDispatch`
via the win32-input-mode mechanism when VT input is enabled.
That is, an `AdaptDispatch` output like `\x1b[C` would otherwise
result in dozens of characters of input.

Related to #16343

## Validation Steps Performed
* Replace conhost with this
* Launch a Win32 application inside WSL
* ASCII keyboard inputs are represented as single `INPUT_RECORD`s ✅

(cherry picked from commit 0da37a1)
Service-Card-Id: 91246942
Service-Version: 1.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-0 Bugs that we consider release-blocking/recall-class (P0) Product-Conpty For console issues specifically related to conpty zInbox-Bug Ignore me!
Projects
Development

Successfully merging this pull request may close these issues.

4 participants