sindresorhus/Actions

Truncate indicator causes odd issues with truncation

Closed this issue · 3 comments

Truncate action seems to take the indicator into account for the number of characters, causing unexpected results:

Screen.Recording.2023-12-14.at.8.29.59.PM.mov

Actions 2.10.0 (51) - com.sindresorhus.Actions
macOS 14.2.0
Mac14,12

That is expected behavior and how most truncation features work. The length is the final string, which includes the truncation character.

I guess it just feels wrong then? The way the action is laid out it reads as, "Truncate this string to this number of characters and add this indicator after." — which is how I expected it to work. The 'add this indicator after' part isn't even initially clear since it's hidden under more.

The default indicator add some oddities as well because while I and some might know the ... is an ellipsis and is considered a single character a vast amount of others might assume it to be three periods, breaking any type of mental model a user might try to form. "Hello with ..." becoming "H..." when truncated to 2 characters, for example.

I will clarify it in the docs in the next update.