Skip to content

tab_switcher: Show full file names without truncation - #58483

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
saberoueslati:tab_switcher/fix-premature-title-truncation
Jun 4, 2026
Merged

tab_switcher: Show full file names without truncation#58483
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
saberoueslati:tab_switcher/fix-premature-title-truncation

Conversation

@saberoueslati

@saberoueslati saberoueslati commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Context

The tab switcher was truncating file names at the same 24-character limit (MAX_TAB_TITLE_LEN) used by the narrow tab bar. This made files that share a long common prefix, like test_cpp_file_long_name.h and test_cpp_file_long_name.cpp, render identically, with both becoming test_cpp_file_long_name.….

The fix adds a max_title_len: Option<usize> field to TabContentParams. When None (the default, used by the tab bar), Editor::tab_content falls back to MAX_TAB_TITLE_LEN as before. The tab switcher passes Some(usize::MAX), which skips truncation entirely and lets the UI container constrain the displayed text naturally.

Closes #58461

How to Review

  • crates/workspace/src/item.rs : Adds max_title_len: Option<usize> to TabContentParams. Derives Default so None is the zero-cost default; two existing struct literals in pane.rs that couldn't use ..Default::default() were updated to be explicit.
  • crates/editor/src/items.rs : In Editor::tab_content, both the title label and the description path now use params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN) instead of the hardcoded constant.
  • crates/workspace/src/pane.rs : Two TabContentParams struct literals updated to include max_title_len: None, preserving the existing 24-char tab bar behaviour.
  • crates/tab_switcher/src/tab_switcher.rs : Sets max_title_len: Some(usize::MAX) in render_match, opting the tab switcher out of truncation.

Video of the manual test below :
Used the same names of the files in the issue but also longer ones to showcase the behavior in different file lengths :

Screencast.from.2026-06-04.00-08-02.webm

I'm obviously open to discussing this further specially the new truncation behavior of the file with the longest name in the manual test.

Self-Review Checklist

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

Release Notes:

  • Fixed tab switcher truncating long file names, making files with a shared prefix indistinguishable

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 3, 2026

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionality seems good to me for this fix.


That brings up another thought though, since this doesn't fix all long filenames. Any which are longer than the tab bar toggle will still run under and truncate abruptly.

Image

Typically the solution for this is a middle-truncation that shows the start and end of the string. In this case offending filenames would look like this, which shows important context at the beginning and end of the string, such as .c and .h.

a_really_really_long...that_is_good.c
a_really_really_long...that_is_good.h

@ChristopherBiscardi ChristopherBiscardi self-assigned this Jun 4, 2026
@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jun 4, 2026
Merged via the queue into zed-industries:main with commit ea7b4c7 Jun 4, 2026
36 checks passed
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 8, 2026
…#58483)

## Context

The tab switcher was truncating file names at the same 24-character
limit (`MAX_TAB_TITLE_LEN`) used by the narrow tab bar. This made files
that share a long common prefix, like `test_cpp_file_long_name.h` and
`test_cpp_file_long_name.cpp`, render identically, with both becoming
`test_cpp_file_long_name.…`.

The fix adds a `max_title_len: Option<usize>` field to
`TabContentParams`. When `None` (the default, used by the tab bar),
`Editor::tab_content` falls back to `MAX_TAB_TITLE_LEN` as before. The
tab switcher passes `Some(usize::MAX)`, which skips truncation entirely
and lets the UI container constrain the displayed text naturally.

Closes zed-industries#58461

## How to Review

- **`crates/workspace/src/item.rs`** : Adds `max_title_len:
Option<usize>` to `TabContentParams`. Derives `Default` so `None` is the
zero-cost default; two existing struct literals in `pane.rs` that
couldn't use `..Default::default()` were updated to be explicit.
- **`crates/editor/src/items.rs`** : In `Editor::tab_content`, both the
title label and the description path now use
`params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN)` instead of the
hardcoded constant.
- **`crates/workspace/src/pane.rs`** : Two `TabContentParams` struct
literals updated to include `max_title_len: None`, preserving the
existing 24-char tab bar behaviour.
- **`crates/tab_switcher/src/tab_switcher.rs`** : Sets `max_title_len:
Some(usize::MAX)` in `render_match`, opting the tab switcher out of
truncation.

Video of the manual test below :
Used the same names of the files in the issue but also longer ones to
showcase the behavior in different file lengths :

[Screencast from 2026-06-04
00-08-02.webm](https://github.com/user-attachments/assets/5f388257-2f3d-494c-ab50-bf46496dbd38)

I'm obviously open to discussing this further specially the new
truncation behavior of the file with the longest name in the manual
test.

## 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
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed tab switcher truncating long file names, making files with a
shared prefix indistinguishable
pull Bot pushed a commit to sipsuru/zed-winbuild that referenced this pull request Jun 11, 2026
…9072)

## Context

This follow-up was inspired by Christopher’s suggestion in the review
comment on zed-industries#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.
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…#58483)

## Context

The tab switcher was truncating file names at the same 24-character
limit (`MAX_TAB_TITLE_LEN`) used by the narrow tab bar. This made files
that share a long common prefix, like `test_cpp_file_long_name.h` and
`test_cpp_file_long_name.cpp`, render identically, with both becoming
`test_cpp_file_long_name.…`.

The fix adds a `max_title_len: Option<usize>` field to
`TabContentParams`. When `None` (the default, used by the tab bar),
`Editor::tab_content` falls back to `MAX_TAB_TITLE_LEN` as before. The
tab switcher passes `Some(usize::MAX)`, which skips truncation entirely
and lets the UI container constrain the displayed text naturally.

Closes zed-industries#58461

## How to Review

- **`crates/workspace/src/item.rs`** : Adds `max_title_len:
Option<usize>` to `TabContentParams`. Derives `Default` so `None` is the
zero-cost default; two existing struct literals in `pane.rs` that
couldn't use `..Default::default()` were updated to be explicit.
- **`crates/editor/src/items.rs`** : In `Editor::tab_content`, both the
title label and the description path now use
`params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN)` instead of the
hardcoded constant.
- **`crates/workspace/src/pane.rs`** : Two `TabContentParams` struct
literals updated to include `max_title_len: None`, preserving the
existing 24-char tab bar behaviour.
- **`crates/tab_switcher/src/tab_switcher.rs`** : Sets `max_title_len:
Some(usize::MAX)` in `render_match`, opting the tab switcher out of
truncation.

Video of the manual test below :
Used the same names of the files in the issue but also longer ones to
showcase the behavior in different file lengths :

[Screencast from 2026-06-04
00-08-02.webm](https://github.com/user-attachments/assets/5f388257-2f3d-494c-ab50-bf46496dbd38)

I'm obviously open to discussing this further specially the new
truncation behavior of the file with the longest name in the manual
test.

## 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
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed tab switcher truncating long file names, making files with a
shared prefix indistinguishable
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…9072)

## Context

This follow-up was inspired by Christopher’s suggestion in the review
comment on zed-industries#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.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…#58483)

## Context

The tab switcher was truncating file names at the same 24-character
limit (`MAX_TAB_TITLE_LEN`) used by the narrow tab bar. This made files
that share a long common prefix, like `test_cpp_file_long_name.h` and
`test_cpp_file_long_name.cpp`, render identically, with both becoming
`test_cpp_file_long_name.…`.

The fix adds a `max_title_len: Option<usize>` field to
`TabContentParams`. When `None` (the default, used by the tab bar),
`Editor::tab_content` falls back to `MAX_TAB_TITLE_LEN` as before. The
tab switcher passes `Some(usize::MAX)`, which skips truncation entirely
and lets the UI container constrain the displayed text naturally.

Closes zed-industries#58461

## How to Review

- **`crates/workspace/src/item.rs`** : Adds `max_title_len:
Option<usize>` to `TabContentParams`. Derives `Default` so `None` is the
zero-cost default; two existing struct literals in `pane.rs` that
couldn't use `..Default::default()` were updated to be explicit.
- **`crates/editor/src/items.rs`** : In `Editor::tab_content`, both the
title label and the description path now use
`params.max_title_len.unwrap_or(MAX_TAB_TITLE_LEN)` instead of the
hardcoded constant.
- **`crates/workspace/src/pane.rs`** : Two `TabContentParams` struct
literals updated to include `max_title_len: None`, preserving the
existing 24-char tab bar behaviour.
- **`crates/tab_switcher/src/tab_switcher.rs`** : Sets `max_title_len:
Some(usize::MAX)` in `render_match`, opting the tab switcher out of
truncation.

Video of the manual test below :
Used the same names of the files in the issue but also longer ones to
showcase the behavior in different file lengths :

[Screencast from 2026-06-04
00-08-02.webm](https://github.com/user-attachments/assets/5f388257-2f3d-494c-ab50-bf46496dbd38)

I'm obviously open to discussing this further specially the new
truncation behavior of the file with the longest name in the manual
test.

## 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
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed tab switcher truncating long file names, making files with a
shared prefix indistinguishable
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…9072)

## Context

This follow-up was inspired by Christopher’s suggestion in the review
comment on zed-industries#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The file tab switcher truncates file names prematurely, before the midpoint of the available space.

2 participants