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/truncateLeft return longer strings than their budget in narrow terminals #41054
truncateLeft and truncateMiddle in packages/tui/src/util/locale.ts compute a slice length that hits zero or goes negative on small budgets. String.prototype.slice(-0) returns the whole string, so both helpers can return something longer than what they were given:
The Math.max(1, ...) at those call sites looks like a guard but clamps right into the broken range. files.tsx:35 uses Math.max(2, ...), which happens to land just outside it.
So the truncate helpers grow the string exactly when the terminal has the least room, and the layout blows out instead of being protected.
Clamping inside the helpers fixes all call sites at once. util/locale.ts currently has no tests. Happy to send a PR with both.
Duplicate of #37458 (and #20880 / #34395 before it). Should have searched before opening this. Closing in favour of the existing issue; my PR #41060 now targets #37458.
Activity
github-actions commentedon Aug 7, 2026
This issue might be a duplicate of existing issues. Please check:
truncateMiddleoff-by-one withslice(-0)on budgets of 1 or 2, same dialog-select call site documentedtruncateLeftoff-by-one atlen === 1Mute-404 commentedon Aug 7, 2026
Duplicate of #37458 (and #20880 / #34395 before it). Should have searched before opening this. Closing in favour of the existing issue; my PR #41060 now targets #37458.