Skip to content
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

Bug in width calculation with multibyte characters. #109

Open
n2naokun opened this issue Apr 8, 2023 · 7 comments
Open

Bug in width calculation with multibyte characters. #109

n2naokun opened this issue Apr 8, 2023 · 7 comments

Comments

@n2naokun
Copy link

n2naokun commented Apr 8, 2023

Note: This text has been translated using DeepL.com.
English
When I use multibyte characters such as Japanese, the frame is not displayed correctly.
Multibyte characters are displayed wider, but all of them seem to be calculated with the same width as alphabets and symbols.

If it is technically possible, we would appreciate it if you could fix this.

Japanese(original)
日本語などのマルチバイト文字を使用した場合枠が正しく表示されません。
マルチバイト文字は幅が広く表示されますが、全てアルファベットや記号と同じ幅で計算されているようです。

技術的に可能でしたら修正していただけると助かります。

blockman

@leodevbro
Copy link
Owner

leodevbro commented Apr 8, 2023

Hi, I think we can make the situation better, but unfortunately it does not seem easy to fully fix it, because VS Code extension API does not expose width of each character or location of each character. So, blockman just calculates block width with 1 general character width times the count of characters in the line.

For now, please try this Blockman command:
Press F1 and find:
Blockman Toggle Try Support Double Width Chars (e.g. Chinese)

image

With this experimental feature, Blockman will try to find Chinese/Japanese/Korean characters and it will try to treat each of them as two characters, so it will look something like this. It is still not correct width, but at least the rectangle is bigger, so the text does not overflow and it feels more natural probably.

image

@n2naokun
Copy link
Author

n2naokun commented Apr 8, 2023

Thank you very much.
It is now easier to read.

@ChenZhouUC
Copy link

Thank you a lot for your help. This is enough for me. Still confused for the one point, is this toggle command thing different from the extension settings since I couldn't find any changes on my VSCODE user settings?

@leodevbro
Copy link
Owner

Yeah, it does not change the settings. It just changes the current state in memory. So, probably you have to rerun the command every time you restart VS Code.

@ChenZhouUC
Copy link

Yeah, it does not change the settings. It just changes the current state in memory. So, probably you have to rerun the command every time you restart VS Code.

Thank you for your kind reply. Found a way to do this automatically. I would like to put it here in case anyone who has similar concern.

Using VSCode's Tasks:
(ref: https://code.visualstudio.com/docs/editor/tasks)

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "blockman",
            "type": "process",
            "command": "${command:blockman.toggleTrySupportDoubleWidthChars}",
            "args": [],
            "group": "none",
            "runOptions": {
                "runOn": "folderOpen"
            }
        }
    ]
}

@ChenZhouUC
Copy link

Still Looking Forward to a formal Setting for this feature. This is indeed a good enough one! I consider wider is better though some outlier cases might occur.

@leodevbro
Copy link
Owner

Thanks for the feedback. I'll try to implement this feature as a formal setting for the next update of Blockman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants