Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Thai combining marks cause width miscalculation in modern terminals (Kitty, Ghostty)

Aperta
#3,957 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Start by inspecting the Thai ranges in _cell_widths.py, then run the supplied Console, Table, and cell_len reproduction with the listed Thai strings. Done means the reported Thai cell lengths match the terminal widths in Kitty and Ghostty, with table columns no longer misaligned.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

Thai combining marks (vowels and tone marks) are marked as zero-width in CELL_WIDTHS, following Unicode's Mn (Nonspacing Mark) classification. However, modern terminal emulators (tested: Kitty, Ghostty) render Thai text with these characters taking visible width, causing table columns and other layouts to misalign.

Reproduction

from rich.console import Console
from rich.table import Table
from rich.cells import cell_len

console = Console()
table = Table(title='Thai Text Width Test')
table.add_column('Text', width=10)
table.add_column('cell_len')

for text in ['สวัสดี', 'น้ำ', 'กรุงเทพ']:
    table.add_row(text, str(cell_len(text)))

console.print(table)

Width Analysis

Text Codepoints Combining marks Rich cell_len Terminal width
สวัสดี 6 2 4 6
น้ำ 3 1 2 3
กรุงเทพ 7 1 6 7

The discrepancy equals the number of combining marks — terminals render each Thai codepoint as width 1.

Affected Ranges in CELL_WIDTHS

Range Characters Unicode Category
U+0E31 ั Mn (sara am vowel)
U+0E34-U+0E3A ิ ี ึ ื ุ ู ฺ Mn (vowel signs)
U+0E47-U+0E4E ็ ่ ้ ๊ ๋ ์ ํ ๎ Mn (tone marks)

Environment

  • Rich: 13.7.1
  • Python: 3.14.2
  • Terminals tested:
    • Kitty 0.45.0 — affected
    • Ghostty 1.2.3 — affected
  • Platform: macOS

Proposed Fix

Change Thai combining mark ranges from width 0 to width 1 in _cell_widths.py. This matches actual terminal rendering behavior for Thai script.

Lingua principale
Python
Stelle
57.6k
Fork
2.4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Textualize/rich

Tutte le issue di Textualize/rich

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.