Fix ambiguous-width character handling for CJK terminals

Open Beginner friendly
#4,199 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
cli

Research direction

Start by locating get_character_cell_size() and the tests covering character-cell widths. Check the existing handling of East Asian Width categories, then verify that ambiguous ("A") characters such as "…" use two cells and that the updated tests pass.

Written by the indexing model from the issue text.

Description

Needs triage

Summary

get_character_cell_size() currently returns a width of 1 for East Asian Width (EAW) ambiguous characters.

Many CJK terminals render these characters using two cells, which can lead to incorrect text alignment.

This PR updates the fallback logic to return 2 for characters whose East Asian Width category is "A".

Testing

  • Verified that get_character_cell_size("…") previously returned 1.
  • Verified that it now returns 2.
  • Added/updated tests for the new behavior.
Dominant language
Python
Stars
57.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Textualize/rich

All issues in Textualize/rich

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.