-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 double-width characters disappearing when wrapping #3180
Conversation
…'s referring to the number of *single-width* characters. Also a small addition to the gitignore file.
…hen the "fold" location sat *within* a double-width character. Ensure we retain browser logic of: if there is no space on the current line, move to a new line, and if theres not enough space on the entire new line, fold the text over multiple lines at appropriate locations.
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #3180 +/- ##
==========================================
- Coverage 98.30% 98.28% -0.03%
==========================================
Files 74 74
Lines 8038 8049 +11
==========================================
+ Hits 7902 7911 +9
- Misses 136 138 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
I suggested a couple of tweaks but they are fairly subjective, so I won't block the merge because of them.
divides: List[int] = [] | ||
append = divides.append | ||
line_position = 0 | ||
def divide_line(text: str, width: int, fold: bool = True) -> list[int]: |
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.
I'm assuming cell_offset
is keeping track of how much space is already occupied in the line we're currently filling, right?
I personally don't love the name but maybe that could be mitigated with a short comment next to it?
Co-authored-by: Rodrigo Girão Serrão <[email protected]>
…ch into double-width-wrapping-fix
Type of changes
Checklist
Description
Update wrapping logic to fix issues with CJK charcters disappearing when the "fold" location sat within a double-width character. Ensure we retain browser logic of:
Adds some additional tests and docstrings, documentation etc.
Fixes #3176
The wrapping process is overall still quite simple and doesn't match the browser in many cases. For example, wrapping does not consider punctuation (lines can begin with punctuation), and whitespace is handled differently (but practically speaking it seems sensible).