-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix Dict limit printing of small values ending with color #45521
Conversation
Did you mark this as draft because you intend to also fix the issue noted in the last comment? |
Yes and I think the Windows CI error might be legit because I don't see it on other builds. I'll try to look at it this weekend. Regarding the issue in the last comment, I can think of a fix consisting in recording the encountered ANSI sequences directly in the |
The diff ends up a bit larger than I thought but to summarize:
|
What's the reason this became so complicated? It seems that naively you just want to write the text but only count characters, when the total number of characters you want is reached, you turn all attributes off and print the three dots, similar to the first implementation that had some off by one or something. |
You're right, it was probably too complicated to maintain. My goal was to modify the string as little as possible, hence only adding a "\033[0m" ANSI sequence when strictly necessary, which meant not adding it when all ANSI start delimiters had their corresponding end delimiters... But let's just simplify it all. In the new commit 596ab8a I just append "\033[0m" if we encountered an ANSI delimiter in the string and the last encountered delimiter was not "\033[0m" itself. As an aside, the previous implementation did not handle characters with width larger than 1 correctly in some corner cases ( |
596ab8a
to
485723e
Compare
5f9f311
to
1ad167f
Compare
Thanks for noticing! There was a |
The recent #37568 added handling of colors in
Dict
printing with:limit => true
in theIOContext
. There is a lingering bug when the last character of the printed value is colored, which results in an additional…
character being printed and color-bleeding, for example in the following picture:This is due to
IgnoreAnsiIterator
skipping the last characters of the value (since they are ANSI end delimiters), then seeing that the entire line has not been printed, and thus wrongly assuming that thelimit
size has been reached.With this PR: