-
Notifications
You must be signed in to change notification settings - Fork 63
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
Hopefully fix unicodes and indented pretty printing #1581
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1581 +/- ##
==========================================
- Coverage 87.17% 86.98% -0.20%
==========================================
Files 115 114 -1
Lines 29565 29686 +121
==========================================
+ Hits 25773 25822 +49
- Misses 3792 3864 +72 ☔ View full report in Codecov by Sentry. |
Thanks. I would like to see a bit more tests, things with non-standard width like '⛵' and where it has to wrap a line. |
Fixed the case where the spilled over line still had unicode. Now looking into characters with non standard widths. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not getting weird errors from unicode chars getting ripped in half is already a great step IMO.
handling chars of different widths and still get visually a fixed with of x columns in the terminal is great to have, but I think much harder to implement. Thus I would be happy to merge as is (with a few more tests) and get everything else in a future PR.
I agree 100% with @lgoettgens . I have zero issues with printing involving double width chars right now, but I've run into errors due to multibyte single width chars in two completely independent situations by now. |
I think most of this could be written very nice and concise using the second dispatch (with UnitRange) of https://docs.julialang.org/en/v1/stdlib/Unicode/#Unicode.graphemes, but unfortunately this is only existent from julia 1.9. So maybe add a comment referencing this so we can rewrite once the compat bound is changed. Or we include the function for older versions ourselves |
I've found a strange bug already, while trying to write a test. Please do not merge this in its current state. |
I marked this as a "draft" PR for now :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look very clean now after the refactoring. Thanks!
Whats left from the comments above: Can you add some tests using something with many combiners (like in #1581 (comment)) and something of non-standard width (like in #1581 (comment))?
Co-authored-by: Lars Göttgens <[email protected]>
…Algebra.jl into ak96/indented_unicodes
No longer crashes when graphemes of non standard width are encountered, but currently does not account for it while calculating when to line break. I will add tests including wide graphemes along with the patch that makes them print in line with other characters. |
According to alacritty/alacritty#265 (comment) , unicode in monospace can only have width 0, 1, or 2, so, just accounting for width 2 (in addition to what we already do) should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just had a quick look. The println(io)
bit must be changed. I think the lowercasefirst
handling should also be changed then as we need to re-run tests anyway, and it simplifies the code. Your choice about the iterators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests look good but there are a few simple optimizations to be had, see the code suggestions. Other than that I am OK with merging this. Feel free to come over to my office to discuss any of these.
Thanks @aaruni96 !!! |
Fixes #1561