Improve code for unsaved tab titles (#32770)

Just fixing a couple of minor things that bugged when revisiting this
code.

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2025-06-15 17:18:09 -04:00 committed by GitHub
parent fd7a133d00
commit 61771e7e4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2607,7 +2607,7 @@ impl MultiBuffer {
return file.file_name(cx).to_string_lossy();
}
if let Some(title) = self.buffer_based_title(buffer) {
if let Some(title) = self.buffer_content_title(buffer) {
return title;
}
};
@ -2615,7 +2615,7 @@ impl MultiBuffer {
"untitled".into()
}
fn buffer_based_title(&self, buffer: &Buffer) -> Option<Cow<'_, str>> {
fn buffer_content_title(&self, buffer: &Buffer) -> Option<Cow<'_, str>> {
let mut is_leading_whitespace = true;
let mut count = 0;
let mut prev_was_space = false;
@ -2647,11 +2647,11 @@ impl MultiBuffer {
let title = title.trim_end().to_string();
if !title.is_empty() {
return Some(title.into());
if title.is_empty() {
return None;
}
None
Some(title.into())
}
pub fn set_title(&mut self, title: String, cx: &mut Context<Self>) {