Skip to content

truncateMiddle returns the whole string when maxLength is 1 or 2 #34395

Description

@Osamaali313

Description

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…".

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions