You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When set 'wap_comments = true', it works fine for English comments. But when write comments in Chinese or Japanese, the long lines more than comment_width do not be wrapped.
The text was updated successfully, but these errors were encountered:
Currently rustfmt's line wrapping is not considering much about East-Asian scripts like Japanese, Chinese.
I just took a quick glance but I can point out at least 2 problems:
The styleguide is not saying anything about this but I think neither str::len() nor Chars::count() should be considered as "line length". The string "ゆゆ式" 's str::len() is 9 and Chars::count() is 3 but in normal monospace glyph it occupies 6 width. Unicode has a TR for this: UAX#11 (rust impl). Though this spec is still leaving us to decide which "context" we should use between CJK and non-CJK contexts. Maybe we can add this setting into rustfmt.toml?
Current line-breaking algorithm is not considering into non-space-separating languages (e.g. CJK). The current implementation is partially using Unicode TR [UAX#29] (rust impl) but it's not something working for CJK. I also feel like we would rather use [UAX#14] to decide the place to insert newline, but unfortunately we don't have official implementation under the official unicode-rs directory today because the TR is not trivial.
So... maybe we should start from implementing [UAX#14]? (just kidding)
When set 'wap_comments = true', it works fine for English comments. But when write comments in Chinese or Japanese, the long lines more than comment_width do not be wrapped.
The text was updated successfully, but these errors were encountered: