diff --git a/bots/client_bot.py b/bots/client_bot.py index f224726..b3e06ea 100644 --- a/bots/client_bot.py +++ b/bots/client_bot.py @@ -50,7 +50,7 @@ def _display_width(s: str) -> int: cp = ord(ch) if (0x0400 <= cp <= 0x04FF or 0x0500 <= cp <= 0x052F or 0x2E80 <= cp <= 0x9FFF or 0xF900 <= cp <= 0xFAFF or - 0xFE30 <= cp <= 0xFE4F): + 0xFE30 <= cp <= 0xFE4F or cp in (0x2026, 0x2116)): w += 2 else: w += 1 @@ -60,7 +60,7 @@ def _display_width(s: str) -> int: def _pad_col(s: str, width: int) -> str: cur = _display_width(s) if cur > width: - # Truncate to fit: cut chars until it fits, add "…" + # Truncate to fit, then pad to exactly width result = [] w = 0 for ch in s: @@ -69,7 +69,9 @@ def _pad_col(s: str, width: int) -> str: break result.append(ch) w += cw - return ''.join(result) + '…' + truncated = ''.join(result) + '…' + pad_to = width - _display_width(truncated) + return truncated + ' ' * max(0, pad_to) return s + ' ' * (width - cur)