Skip to content

ls-cjk-width

Provenance

  • Source: .spec/spexcode/spec-cli/sessions/ls-cjk-width/spec.md
  • Source SHA-256: 65d5abd4f59a5d5f96770f19e1f68634732deff2bc9e707bfe997115a3b135ca

ls-cjk-width

raw source

A CJK-titled session wrecked the spex session ls table: the TITLE column was cut with slice(0, 22) — shearing a label mid-word by code units — and padded with padEnd(22), which counts a double-width glyph as one cell, so every column to the right of a CJK label (or PROMPT) drifted left and the table stopped reading as a table.

expanded spec

Cells, not code units. The table's unit of alignment is the terminal CELL. sessions.ts carries three width-aware helpers — displayWidth (a small wcwidth-style range check over the wide blocks: CJK ideographs, kana, Hangul, fullwidth forms, emoji — deliberately no dependency), truncWidth (truncate to a cell budget, the ellipsis paying its own cell, never splitting a wide glyph), and padWidth (pad to a cell budget) — and formatTable's TITLE and PROMPT columns (and the NOTE cap) cut and pad through them. The TITLE field is the session's shared derived title, not its stable selector label or raw node: the latter two remain available for matching and JSON consumers but are not a second visible identity. A pure-ASCII table renders byte-for-byte as the classic padEnd output, so the width fix is invisible until a wide glyph appears.

Out of scope. Label derivation is untouched — a node-agnostic session falling back to its prompt-derived title is [[session-label]]'s contract, and this node only owns how any derived string is fitted into a column. Ambiguous-width code points (e.g. ×) count one cell, matching common terminal wcwidth behaviour.