-
Notifications
You must be signed in to change notification settings - Fork 146
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
Unexpected line breaks occur when Completions contains Chinese characters. #713
Comments
Thank you for reporting the problem. I would like to fix it, but I'll need your help. First, it is necessary to clarify some things: That hint text was added in v1.5.14, more than one year ago. But in v1.7.0, the hint text changed from "Accept Suggestion" to "Insert Suggestion". And in v1.7.0, big changes were made to the algorithm that tries to predict the width of characters in the terminal. I think what you mean is that starting in v1.7.0, the width of Chinese characters is being predicted incorrectly. Unfortunately, the Unicode standard has a large range of Chinese characters which have different widths depending on what system code page is used. They are called "Ambiguous Width" characters in the Unicode standard. When the system code page is not a CJK code page, then the new algorithm is very accurate. But I can't test how the CJK code pages behave for the large range of "Ambiguous Width" Chinese characters, because my operating system language does not use those CJK code pages (CJK refers to Chinese, Japanese, Korean). So, I need to ask some questions:
|
Sorry, I made an error in the description of the version. I retested it: Test content:
Test results (Activity code page: 936):
Test results (Active code page: 65001):
Try upgrading Clink on Windows 11 computer (1.7.5 -> 1.7.6):
I am willing to run a special program to test character width. |
@kagurazakayashi Thank you very much for the updated information -- it is extremely useful, and I'm able to reproduce the problem on my English computer! The problem was introduced by this commit: I see the mistake. Fortunately, it is a simple logic mistake and should be easy to correct. When running on Win 10 or 11 in a terminal other than Windows Terminal, it accidentally skips the measurement logic for codepoints U+2E80 through U+A4CF and for codepoints U+AC00 through U+D7A3. I'll make a fix today or tomorrow. It may take some time because I intend to do extensive testing to confirm the fix on several different terminal programs and OS versions (and also track down how my original testing missed the case). In the meantime, you can avoid the problem by either:
|
I tracked down how my testing missed it: My wcwidth-verifier project did not fully automatically configure itself. And so when running in terminals other than Windows Terminal, it accidentally always used the full emoji-enabled width measurement function, unless specifically told to use the function optimized for other terminals. So if I missed adding the right flag, then it tested the wrong function. I'm updating the wcwidth-verifier program to fully auto-configure itself by default, to avoid similar problems in the future. |
@kagurazakayashi v1.7.7 has been published with the fix. Thank you again for reporting the issue, and for providing such thorough and useful troubleshooting information!! |
Unexpected line breaks occur when Completions contains Chinese characters.
It works properly when only English is included:
If it contains Chinese, it will cause unexpected line breaks:
Misalignment occurs after Tab fills or continues typing:
If press BACKSPACE, a lot of characters will be deleted, or half a Chinese character will remain:
Repeated editing in the rows can cause the actual submission to not match the input display:
The problem started to appear in versions with the
Right=Insert Suggestion
prompt on the right side.The text was updated successfully, but these errors were encountered: