-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-139246: zero-width word paste can be wrong in default repl #139254
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,14 @@ class ColorSpan(NamedTuple): | |
| def str_width(c: str) -> int: | ||
| if ord(c) < 128: | ||
| return 1 | ||
| # gh-139246 for zero-width joiner and combining characters | ||
| if unicodedata.combining(c): | ||
| return 0 | ||
| category = unicodedata.category(c) | ||
| if category == "Cf" and c != "\u00ad": | ||
| return 0 | ||
| if "\u2028" <= c <= "\u2029": | ||
|
||
| return 0 | ||
| w = unicodedata.east_asian_width(c) | ||
| if w in ("N", "Na", "H", "A"): | ||
| return 1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| fix: paste zero-width in default repl width is wrong. |
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.
unrelated to this issue but quite a few of the characters with ord < 128, do not have a display width of 1
for example, in my terminal, tab (ord 9) is 8 charaters wide
something to consider for a future PR