Repository navigation
bugfix infinite loop in Terminal.wrap - #275
Conversation
From #273, > The following code enters an infinite loop: import blessed blessed.Terminal().wrap('\u5973', 1) This fixes by explicit test: when the given individual sequence is of length '2', and the width is '1', and the cur_len is '0', we cannot break down this "Wide" character any further -- so it is allowed to flow outside the given cell. - 'faulthandler_timeout = 30' is added to [pytest] in tox.ini, - Tests for East-Asian, Emoji, and ZWJ are added - Further noting that blessed gets ZWJ wrong
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #275 +/- ##
==========================================
+ Coverage 95.56% 95.57% +0.01%
==========================================
Files 10 10
Lines 1037 1040 +3
Branches 177 165 -12
==========================================
+ Hits 991 994 +3
Misses 43 43
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| nxt += len(text) | ||
| if Sequence(chunk[:nxt], term).length() > space_left: | ||
| break | ||
| seq_length = Sequence(chunk[:nxt], term).length() |
There was a problem hiding this comment.
when seq_length is equal to space_left, the for loop does the next chunk even though there is no space remaining
is there another small optimization possible to call length fewer times? something like:
if seq_length == space_left:
idx = nxt
break
elif seq_length > space_left:
...
There was a problem hiding this comment.
There are many unicode characters that consume 0 cells, https://wcwidth.readthedocs.io/en/latest/specs.html#width-of-0, there are examples of this in the ZWJ test added, though it gets it wrong in that specific case, we would prefer to cojoin with 1,800+ possible Combining Marks that might follow, like in cafe\u0301 we would not wish to break immediately after the letter 'e', because the next character \u0301 is desired
There was a problem hiding this comment.
Added test in 6beb3c6 hope that makes it more clear
|
yes, sure, i'll do it soon |
_line_buffered *is* defined in the __init__ method of base Terminal class which is derived here
|
This is released, although the wheel has uploaded I'm having a problem with pushing the source tarball, it should get online eventually |
Closes #273 by @grayjk,
This fixes by explicit check: when
we cannot break down this "Wide" character any further -- so it is allowed to flow outside the given cell.
faulthandler_timeout = 30is added to[pytest]in tox.ini