-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Bug Report: What is reordering VT escape sequences in my string? #2011
Comments
I'm willing to bet serious money that when conhost in conpty mode processes a long string with VT sequences in it that conhost doesn't understand, we render the failing VT sequences before we repaint for the rest of the string. So for your example string: Conhost is going to try and process that entire string in one frame. Conpty is only going to render the output at the end of a frame, once every 60th of a second. However, as soon as the adapter ( Possible solutions:
$push = "${esc}[#p"
$red = "${esc}[91m"
$pop = "${esc}[#q"
$reset = "${esc}[0m"
$s1 = "Hello. Push:"
$s2 = "this text is RED Pop:${esc}[#q FG should no longer be red (unless it was red before) courtesy reset: ${esc}[0m"
$s3 = "FG should no longer be red (unless it was red before) courtesy reset: "
|
Whoa. Interesting. Thanks for the explanation, @zadjii-msft ; I would never have figured that out. Part of my problem seems to be a debugging problem: in my branch with some code changes to handle those sequences, I implemented the push/pop commands in the But the code definitely IS running... if I change the Although I don't understand the changed behavior... now the push/pop control sequences are simply gone. Should the |
Oh that's because debugging the Terminal's conhost is a pain. Basically, Windows Terminal is running attached to another conhost process, and that conhost process is where adaptDispatch is running. To be able to debug it with VS, you need to manually attach VS to the child conhost process that the Terminal started. |
Marking this one triaged; it's definitely something we should look at, but we may not have the bandwidth to do so. |
…h the frame ## Summary of the Pull Request When Conpty encounters a string we don't understand, immediately flush the frame. ## References This PR superceeds #2665. This solution is much simpler than what was proposed in that PR. As mentioned in #2665: "This might have some long-term consequences for #1173." ## PR Checklist * [x] Closes #2011 * [x] Closes #4106 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated
When ConPTY encounters a string we don't understand, immediately flush the frame. ## References This PR supersedes #2665. This solution is much simpler than what was proposed in that PR. As mentioned in #2665: "This might have some long-term consequences for #1173." ## PR Checklist * [x] Closes #2011 * [x] Closes #4106 * [x] I work here * [x] Tests added/passed
Environment
I am working on implementing some new VT escape sequences (PR here), but I've run into a strange problem. What the sequences do (or are supposed to do) is not important here. The problem is that in certain circumstances, something is reordering VT escape sequences in my content (which is very surprising to me).
The control sequences in question are XTPUSHSGR and XTPOPSGR:
[CSI]#p
and[CSI]#q
, respectively. Note in the string below, how there is an XTPUSHSGR sequence, then a normal SGR sequence to set the color to red, then an XTPOPSGR sequence (and then a normal SGR sequence to reset the color).When I open OpenConsole.sln in Visual Studio 2019, with the CascadiaPackage set as the default project to debug, and then F5 to start debugging it, it launches a terminal running Windows PowerShell. When I send my string to the console, something is moving the XTPUSHSGR and XTPOPSGR sequences to the very beginning of the string!
Steps to reproduce
TerminalControl.dll!Microsoft::Console::VirtualTerminal::StateMachine::ProcessString
(the two-parameter one).$s
to output the string.rgwch
.Expected behavior
The content of the string should be just as it was set in PowerShell.
Actual behavior
The XTPUSHSGR and XTPOPSGR sequences have been moved to the beginning of the string!
My first thought was that PowerShell must be doing something funny, but I attached windbg to the PowerShell and set a breakpoint on kernel32!WriteConsoleW, and the string passed in there is correct. So something is happening after the string has left PowerShell's hands.
The text was updated successfully, but these errors were encountered: