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
truncateMiddle returns the whole string when maxLength is 1 or 2 #34395
truncateMiddle (packages/tui/src/util/locale.ts) returns the whole string — longer than the input — when maxLength is 1 or 2. At those widths keepEnd is 0, and str.slice(-0) slices from index 0 (returns everything) instead of nothing. The run splash detail line (splash.ts, which calls truncateMiddle(detail, Math.max(1, width - body_left))) can overflow on very narrow terminals.
Steps to reproduce
truncateMiddle("hello-world", 1) returns "…hello-world" (length 12) and truncateMiddle("hello-world", 2) returns "h…hello-world" (length 13). Expected "…" and "h…".
Activity
github-actions commentedon Jun 29, 2026
This issue might be a duplicate of existing issues. Please check:
truncateMiddlereturns the full string whenmaxLengthis 1 or 2 due toslice(-0)Osamaali313 commentedon Jun 29, 2026
Closing as a duplicate of #20880 (same
truncateMiddle/slice(-0)bug). The fix is in #34482, now linked to #20880.