-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Strings with Virtual Terminal (VT) / ANSI escape sequences that are truncated for display make effects linger #7767
Comments
I would like to know that there is a better practice for working with VT. |
What do you mean by that, @iSazonov? |
It seems we could go with a simple approach and always reset the console color anytime after we truncate. |
That's promising, @SteveL-MSFT; it will definitely work with colors, but is there an equivalent generic reset mechanism for other types of escape sequences, such as the OSC sequences mentioned in #7744? (There may be, I haven't checked).
|
We don't want to see escapes in trace log. So we need a rendering subsystem. |
|
That smells like a bug, @SeeminglyScience, and I actually can't reproduce it on Microsoft Windows 10 Pro (64-bit; Version 1803, OS Build: 17134.285) Does the following really not work for you? "before `e[4munderlined`e[m after" |
@mklement0 huh, it does now. I wonder if a Windows update fixed that or if I'm just thinking of something else... Either way nevermind :) |
I made the same comment on #7744, but: DbgShell's approach is not to try to reset/undo escape sequences; rather just leave them all in. In other words, when truncating, it only truncates content, but preserves all escape sequences (code here). That said, resetting does seem like a good idea in general for a formatting engine. I came searching for Issues after running |
…le`; Replace `...` with unicode ellipsis (#8326) change ellipsis when truncating to single unicode character reset console output if previous column contains ESC update existing format-table tests If content included a VT100 ESC sequence (like changing color), this affected all output after that cell in the table. Fix is to detect that a cell contained ESC and reset the console after it. Also, change the 3 character ellipsis `...` to use the single unicode character `…` so that more text is available. Fix #7767
Related: #7744
Virtual Terminal escape sequences allow, among other things, formatting of console (terminal) output, notably to produce colored output.
An escape sequence that changes the output color - e.g.,
"`e[32m"
to switch to green - stays in effect until the color is reset - e.g., with"`e[m"
Example:
Therefore, if PowerShell truncates strings for output formatting, a string may get cut off so that the reset sequence is not output, which means that the color unexpectedly stays in effect.
#7744 shows the problem in the context of using an OSC escape sequence to construct a hyperlink (which only some terminals support; others render just the link label).
This is a nontrivial problem to solve, because PowerShell would have to be aware of all potential escape sequences and know how to reset their effects so that the appropriate escape sequence can be appended to the truncated string.
Steps to reproduce
Expected behavior
gr...
should render green, butnext col
should render with the default color.Actual behavior
That is,
next col
too is printed in green, and green output stays in effect (the prompt rendered after the command will be green too).Additionally, note that the column alignment is off.
Environment data
The text was updated successfully, but these errors were encountered: