Skip to content

[Bug] M7: Display width ≠ character count — wide/combining chars misalign every bordered surface #47

Description

@fissible

Source: external review report, 2026-08-24 (severity: Medium)

Problem

src/clip.sh:55shellframe_str_len() is ${#1} (code points, not columns). Every aligned surface — panel borders, table columns, grid, diff side-by-side, form fields — misaligns on CJK/emoji (width 2) and over-counts combining sequences (width 0).

Defensible as an ASCII-scoped limitation, but the docs don't state it, and "VT100-compatible" implies more than it delivers.

Options

A. Document the limitation (XS) — README + docs/api.md: "Layout assumes single-column characters. Wide (CJK/emoji) and combining characters will misalign borders." Ship this regardless.

B. wcwidth approximation (M)shellframe_str_width() using a small range table (CJK Unified, Hangul, fullwidth forms, common emoji blocks → 2; combining marks → 0). Pure bash, no external tools. Swap call sites in clip/panel/table/grid/diff. Must stay fast enough on 3.2 — benchmark before adopting.

Recommend A immediately, B as a Phase 7 enhancement.

Tests

  • Unit: shellframe_str_width '日本' → 4; combining é (e + U+0301) → 1
  • ptyunit: table with a CJK cell renders aligned borders

Effort: XS (A) / M (B)
Deps: none. Related: #54 (wide-char strategy).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions