You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
truncateLeft returns a longer string than the input when len is 1 #37368
truncateLeft(str, len) in packages/tui/src/util/locale.ts returns a string longer than the input when len === 1.
It ends with "…" + str.slice(-(len - 1)). At len === 1 that's str.slice(-0), and slice(-0) is slice(0) — the whole string. So truncateLeft("abcdef", 1) returns "…abcdef" (7 chars) instead of "…" (1 char).
The sibling truncate() right above it handles the same edge correctly (str.slice(0, 0) + "…" → "…"), so this is an inconsistency between the two.
Current callers all pass a width ≥ 2 (e.g. Math.max(2, ...)), so it isn't hit in practice today — but it's a latent off-by-one that will overflow the moment a caller passes 1.
Steps to reproduce
import { truncateLeft } from "packages/tui/src/util/locale.ts"
Activity
github-actions commentedon Sep 15, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.