# tab_switcher: Middle-truncate long picker filenames \(\#59072\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/03a8544040ff95ec2e7921ca71c83799ad7f17cd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 03a8544040ff95ec2e7921ca71c83799ad7f17cd

Requested commit: 03a8544040ff95ec2e7921ca71c83799ad7f17cd

Commit: 03a8544040ff95ec2e7921ca71c83799ad7f17cd

Tree: 9df2fbc41c3b51352ba19d244a81b61d4b5ff447

Author: saberoueslati

Committer: GitHub

## Message

```
tab_switcher: Middle-truncate long picker filenames (#59072)

## Context

This follow-up was inspired by Christopher’s suggestion in the review
comment on #58483: long filenames should truncate in the middle so both
the beginning and the suffix/extension remain visible.

Previously, very long filenames in picker rows could still be clipped or
end-truncated, making files with shared prefixes hard to distinguish.
This adds middle-truncation support to GPUI text overflow and applies it
to filename-focused picker surfaces: the tab switcher and the Ctrl-P
file finder. Normal editor tab bar behavior remains unchanged and
continues to use the existing title length cap.

## How to Review

- **`crates/gpui/src/style.rs`, `crates/gpui/src/styled.rs`,
`crates/gpui/src/elements/text.rs`,
`crates/gpui/src/text_system/line_wrapper.rs`**: Adds
`TextOverflow::TruncateMiddle`, wires it through text layout, and
implements middle truncation while preserving valid text runs. Very
narrow widths now show the truncation affix instead of falling back to
the abruptly clipped original text.

- **`crates/ui/src/components/label/label_like.rs`,
`crates/ui/src/components/label/label.rs`,
`crates/ui/src/components/label/highlighted_label.rs`**: Exposes middle
truncation through the shared label components.

- **`crates/workspace/src/item.rs`, `crates/editor/src/items.rs`,
`crates/workspace/src/pane.rs`,
`crates/tab_switcher/src/tab_switcher.rs`**: Adds an explicit
tab-content opt-in for middle truncation. The tab switcher enables it,
while the normal tab bar and dragged tabs keep their existing behavior.

- **`crates/file_finder/src/file_finder.rs`**: Applies middle truncation
to Ctrl-P file finder filenames and lets the path shrink from the start
so long paths do not hide important filename suffixes.

Manual test before change :

[Screencast from 2026-06-10
22-59-28.webm](https://github.com/user-attachments/assets/5e032646-a48c-45f2-8fe2-0424507fd576)

Manual test after change :

[Screencast from 2026-06-10
22-54-48.webm](https://github.com/user-attachments/assets/4b9253da-f169-4ed1-bdd5-ee71dcf49a83)


## Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the UI/UX checklist
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved long filename truncation in the tab switcher and file finder
so extensions remain visible.
```

## Parents

- [053ea47e5ac15c330dd62b669ca41b8a64ff3f02](https://git.cafe/gitcafe/zed/commit/053ea47e5ac15c330dd62b669ca41b8a64ff3f02?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/03a8544040ff95ec2e7921ca71c83799ad7f17cd?format=markdown)
