Liu Jinyi
69bdef38ec
editor: Fix inconsistent search behavior for untitled/temporary tabs ( #37086 )
...
Closes #37597
Release Notes:
- N/A
---
## Problem
When using "Tab Switcher: Toggle All", temporary files (untitled buffers
without associated file paths) cannot be searched by their displayed
content. This creates an inconsistent user experience where:
- **UI Display**: Shows dynamic titles based on the first line of
content (up to 40 characters)
- **Search Text**: Only searches for the static text "untitled"
### Example
- A temporary file containing `Hello World` is displayed as "Hello
World" in the tab
- However, searching for "Hello" in Tab Switcher returns no results
- Only searching for "untitled" will find this temporary file
## Root Cause
The issue stems from inconsistent title generation logic between display
and search:
1. **Display Title** (`items.rs:724`): Uses `self.title(cx)` →
`MultiBuffer::title()` → `buffer_content_title()`
- Returns the first line of content (max 40 chars) for temporary files
2. **Search Text** (`items.rs:650-656`): Uses `tab_content_text()`
method
- Returns hardcoded "untitled" for files without paths
## Solution
Modified the `tab_content_text()` method in `crates/editor/src/items.rs`
to use the same logic as the displayed title for consistency:
```rust
fn tab_content_text(&self, detail: usize, cx: &App) -> SharedString {
if let Some(path) = path_for_buffer(&self.buffer, detail, true, cx) {
path.to_string_lossy().to_string().into()
} else {
// Use the same logic as the displayed title for consistency
self.buffer.read(cx).title(cx).to_string().into()
}
}
```
2025-09-07 11:33:17 -07:00
..
2025-09-04 17:14:53 +02:00
2025-08-25 16:04:44 -06:00
2025-09-04 17:14:53 +02:00
2025-09-04 09:09:28 +02:00
2025-09-03 22:10:14 +00:00
2025-09-04 05:39:55 +00:00
2025-09-04 18:16:25 -04:00
2025-09-04 15:19:02 -04:00
2025-09-06 13:39:21 +00:00
2025-09-04 00:03:32 +00:00
2025-09-04 06:02:13 +02:00
2025-08-19 21:26:17 +02:00
2025-08-13 13:25:52 -06:00
2025-09-04 17:14:53 +02:00
2025-08-27 23:24:19 +00:00
2025-08-28 13:32:30 -06:00
2025-08-27 23:24:19 +00:00
2025-09-04 17:14:53 +02:00
2025-09-04 15:19:02 -04:00
2025-09-04 15:19:02 -04:00
2025-08-29 17:18:52 -07:00
2025-08-20 12:20:13 +02:00
2025-07-22 11:55:24 -04:00
2025-08-29 18:13:06 -04:00
2025-08-27 23:24:19 +00:00
2025-09-04 17:14:53 +02:00
2025-09-04 15:19:02 -04:00
2025-09-04 17:14:53 +02:00
2025-09-03 03:49:04 +00:00
2025-09-05 12:40:47 -04:00
2025-08-22 11:45:47 -04:00
2025-08-07 01:28:41 +00:00
2025-08-11 15:34:34 +02:00
2025-09-04 17:14:53 +02:00
2025-09-05 21:50:51 +02:00
2025-08-26 00:27:52 +00:00
2025-09-05 14:22:32 +02:00
2025-08-20 12:20:13 +02:00
2025-09-03 00:03:56 +00:00
2025-09-05 14:22:32 +02:00
2025-08-21 19:59:42 -04:00
2025-08-19 21:26:17 +02:00
2025-09-04 15:19:02 -04:00
2025-08-28 07:53:32 +00:00
2025-09-03 22:10:14 +00:00
2025-08-20 12:20:13 +02:00
2025-09-05 21:35:28 +00:00
2025-09-04 05:51:48 +00:00
2025-09-04 15:30:23 +00:00
2025-08-27 03:24:50 +08:00
2025-08-22 11:45:47 -04:00
2025-08-22 11:45:47 -04:00
2025-09-07 11:33:17 -07:00
2025-08-20 20:14:30 +02:00
2025-07-10 21:08:43 +02:00
2025-08-19 20:33:44 +00:00
2025-08-20 12:05:58 +02:00
2025-08-16 19:00:31 +00:00
2025-09-04 15:19:02 -04:00
2025-09-04 15:19:02 -04:00
2025-09-02 17:57:29 -04:00
2025-08-21 19:59:42 -04:00
2025-09-06 00:47:39 +02:00
2025-08-19 21:26:17 +02:00
2025-09-06 00:27:14 +02:00
2025-08-19 13:27:24 +00:00
2025-08-06 10:53:20 +02:00
2025-08-20 20:14:30 +02:00
2025-09-04 15:19:02 -04:00
2025-09-04 15:19:02 -04:00
2025-09-04 15:19:02 -04:00
2025-08-28 12:00:44 +00:00
2025-09-06 16:51:51 +00:00
2025-08-29 16:56:10 -04:00
2025-08-21 17:19:57 +00:00
2025-08-19 13:27:24 +00:00
2025-08-20 12:20:13 +02:00
2025-08-28 07:53:32 +00:00
2025-09-04 15:19:02 -04:00
2025-09-02 20:18:15 -03:00
2025-08-18 21:54:35 +00:00
2025-08-19 20:33:44 +00:00
2025-09-04 15:19:02 -04:00
2025-09-02 20:18:15 -03:00
2025-09-06 00:47:39 +02:00
2025-09-04 09:22:19 +00:00
2025-09-03 01:13:46 +02:00
2025-09-06 07:42:15 +02:00
2025-08-19 13:27:24 +00:00
2025-09-06 07:37:59 +00:00
2025-09-06 01:36:36 +02:00
2025-09-05 09:52:57 -07:00
2025-08-21 15:56:16 +02:00
2025-09-03 01:22:57 +02:00
2025-08-29 17:08:42 +03:00
2025-08-26 12:55:40 -03:00
2025-08-31 11:43:24 +03:00
2025-08-20 12:20:13 +02:00
2025-09-03 01:22:57 +02:00
2025-09-04 17:14:53 +02:00
2025-07-17 14:25:55 +00:00
2025-08-19 20:33:44 +00:00
2025-08-19 13:27:24 +00:00
2025-08-06 10:44:15 -04:00
2025-09-04 15:19:02 -04:00
2025-09-03 01:22:57 +02:00
2025-09-06 07:42:15 +02:00
2025-09-04 15:19:02 -04:00
2025-08-20 12:20:13 +02:00
2025-08-29 17:18:52 -07:00
2025-08-20 12:20:13 +02:00
2025-08-19 21:26:17 +02:00
2025-09-06 07:37:59 +00:00
2025-09-04 15:19:02 -04:00
2025-08-29 14:07:27 -03:00
2025-08-20 12:20:13 +02:00
2025-09-06 00:47:39 +02:00
2025-09-04 15:19:02 -04:00
2025-08-19 13:27:24 +00:00
2025-09-03 14:24:32 -07:00
2025-09-05 17:03:42 -04:00
2025-09-06 00:47:39 +02:00
2025-09-03 00:52:04 +00:00
2025-08-19 13:27:24 +00:00
2025-09-06 04:22:55 +00:00
2025-09-04 17:14:53 +02:00
2025-08-28 03:51:22 +00:00
2025-09-04 17:14:53 +02:00
2025-09-05 00:26:37 +00:00
2025-08-20 12:20:13 +02:00
2025-08-19 13:27:24 +00:00
2025-09-04 22:30:48 +00:00
2025-08-20 12:20:13 +02:00
2025-09-05 14:22:32 +02:00
2025-09-04 22:30:48 +00:00
2025-08-19 21:26:17 +02:00
2025-08-19 21:26:17 +02:00
2025-08-19 13:27:24 +00:00
2025-09-06 01:09:50 +00:00
2025-08-20 12:20:13 +02:00
2025-08-19 20:33:44 +00:00
2025-09-04 17:14:53 +02:00
2025-09-04 17:14:53 +02:00
2025-08-29 16:17:22 -04:00
2025-08-19 21:26:17 +02:00
2025-08-19 20:33:44 +00:00
2025-08-21 19:59:42 -04:00
2025-08-28 21:07:02 +00:00
2025-09-05 14:57:58 +00:00
2025-08-20 14:35:59 +00:00
2025-08-19 21:26:17 +02:00
2025-08-15 15:37:52 -04:00
2025-09-04 15:19:02 -04:00
2025-09-07 02:01:55 +05:30
2025-09-04 17:14:53 +02:00
2025-09-04 15:19:02 -04:00
2025-08-20 12:20:13 +02:00
2025-08-08 15:34:36 -03:00
2025-09-04 15:19:02 -04:00
2025-09-06 00:47:39 +02:00
2025-09-03 19:52:47 +00:00
2025-08-20 12:20:13 +02:00
2025-07-30 23:03:53 +05:30
2025-09-06 00:27:14 +02:00
2025-08-15 13:54:24 +03:00
2025-09-05 17:34:39 +00:00
2025-09-04 15:19:02 -04:00
2025-08-25 14:28:11 -04:00
2025-08-20 12:20:13 +02:00
2025-08-19 20:33:44 +00:00
2025-09-06 01:09:50 +00:00
2025-09-04 15:19:02 -04:00
2025-08-26 21:08:45 +00:00
2025-09-07 11:16:49 -06:00
2025-09-03 10:59:14 +00:00
2025-09-03 22:10:14 +00:00
2025-09-07 11:16:49 -06:00
2025-09-07 11:16:49 -06:00
2025-09-06 00:27:14 +02:00
2025-09-04 15:19:02 -04:00