Improve truncate efficiency and fix OBOE in truncate_and_remove_front (#22591)

* Skip walking string for truncate when byte len is <= char limit

* Fix `truncate_and_remove_front` returning string that is `max_chars +
1` in length. Now more consistent with `truncate_and_trailoff` behavior.

* Fix `truncate_and_remove_front` adding ellipsis when max_chars == char
length

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-02 15:35:36 -07:00 committed by GitHub
parent f9df8c1729
commit 2d431e9b51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 8 deletions

View file

@ -570,7 +570,7 @@ mod tests {
spawn_in_terminal.label,
format!(
"test label for 1234 and …{}",
&long_value[..=MAX_DISPLAY_VARIABLE_LENGTH]
&long_value[long_value.len() - MAX_DISPLAY_VARIABLE_LENGTH..]
),
"Human-readable label should have long substitutions trimmed"
);