Repository navigation
fix(tui): truncateMiddle returns the whole string when maxLength is 1 or 2 - #34342
Osamaali313 wants to merge 1 commit into
Conversation
keepEnd is 0 at those widths, and str.slice(-0) returns the entire string, so truncateMiddle produced output longer than the input (e.g. the run splash detail line overflows on narrow terminals). Skip the end slice when keepEnd is 0.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found The search found one related PR (#32470 "fix(tui): truncate labels by display width") which addresses a different truncation concern, but it is not a duplicate of PR #34342. PR #34342 is specifically fixing a bug in the |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
At maxLength 1 or 2,
keepEndis 0 andstr.slice(-0)returns the entire string, sotruncateMiddlereturns output longer than its input (e.g. the run splash detail line overflows on very narrow terminals). Fix: skip the end slice whenkeepEndis 0. Added a unit test for the small-width cases.