-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Description
Environment
Windows build number: Microsoft Windows [Version 10.0.18362.239]
Windows Terminal version (if applicable): (built from latest source as of July 17th, 2019, morning)
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
- Start OpenConsole.sln in Visual Studio 2019. Make sure CascadiaPackage is the default project, and platform is set to x64, and build the solution if necessary.
- F5 to start debugging a new instance. You should now have a PowerShell instance in the terminal.
- In the PowerShell instance in the terminal, run the following commands:
$esc = [char] 0x1b
$s = "Hello. Push:${esc}[#p ${esc}[91m this text is RED Pop:${esc}[#q FG should " +
"no longer be red (unless it was red before) courtesy reset: ${esc}[0m"
- Set a breakpoint at
TerminalControl.dll!Microsoft::Console::VirtualTerminal::StateMachine::ProcessString
(the two-parameter one). - In the PowerShell instance in the terminal, run the command
$s
to output the string. - When you hit the breakpoint, observe the value of
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.