Skip to content

Fix CJK character display width calculation#200

Open
hurou927 wants to merge 1 commit intoYS-L:mainfrom
hurou927:fix/cjk-display-width
Open

Fix CJK character display width calculation#200
hurou927 wants to merge 1 commit intoYS-L:mainfrom
hurou927:fix/cjk-display-width

Conversation

@hurou927
Copy link
Copy Markdown

@hurou927 hurou927 commented Mar 22, 2026

Summary

  • Fix overlapping rows when displaying CSV files containing CJK (Chinese, Japanese, Korean) characters
  • Replace .len() (byte length) and .chars().count() (character count) with unicode-width crate for correct
    terminal display width calculation
  • Handle line wrapping correctly for CJK characters (width 2) that don't fit in remaining column space

#199

@hurou927 hurou927 force-pushed the fix/cjk-display-width branch from 3d42cfb to b7cb846 Compare March 22, 2026 02:36
@stsymbaliuk
Copy link
Copy Markdown

Hi @hurou927,
Looks like the original issue was not fixed by your current commit.
The issue is reproducible with csvlens 0.15.1 when I set too small font in my terminal. With larger fonts the issue is not reproducible with csvlens 0.15.1.
Also with your modifications I see no difference in csvlens behavior.
Here is a screenshot for build with your modifications. With such font size it still works:
image
But with small fort size it show overlapping:
image

Please confirm the same is reproducible for you.

@YS-L
Copy link
Copy Markdown
Owner

YS-L commented Mar 29, 2026

Thanks @stsymbaliuk for testing! I've pushed a fix in main that should fix the issue, more context here: #199 (comment)

@stsymbaliuk
Copy link
Copy Markdown

Thank you @YS-L ,
With the latest code from main branch the issue with test wrapping with small text size is fixed for me.

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

Successfully merging this pull request may close these issues.

3 participants