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

@ -791,7 +791,7 @@ mod tests {
assert_eq!(
task_names(&tasks_picker, cx),
vec![
"hello from …th.odd_extension:1:1".to_string(),
"hello from …h.odd_extension:1:1".to_string(),
"opened now: /dir".to_string()
],
"Second opened buffer should fill the context, labels should be trimmed if long enough"
@ -820,7 +820,7 @@ mod tests {
assert_eq!(
task_names(&tasks_picker, cx),
vec![
"hello from …ithout_extension:2:3".to_string(),
"hello from …thout_extension:2:3".to_string(),
"opened now: /dir".to_string()
],
"Opened buffer should fill the context, labels should be trimmed if long enough"