Git: Fix prompts with a very large number of filenames (#25629)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2025-02-25 23:29:17 -07:00 committed by GitHub
parent 7f214ed25a
commit dd1ff9b998
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -854,11 +854,15 @@ impl GitPanel {
1 => return self.revert_entry(&entries[0], window, cx),
_ => {}
}
let details = entries
let mut details = entries
.iter()
.filter_map(|entry| entry.repo_path.0.file_name())
.map(|filename| filename.to_string_lossy())
.take(5)
.join("\n");
if entries.len() > 5 {
details.push_str(&format!("\nand {} more…", entries.len() - 5))
}
#[derive(strum::EnumIter, strum::VariantNames)]
#[strum(serialize_all = "title_case")]
@ -908,7 +912,7 @@ impl GitPanel {
_ => {}
};
let details = to_delete
let mut details = to_delete
.iter()
.map(|entry| {
entry
@ -918,8 +922,13 @@ impl GitPanel {
.map(|f| f.to_string_lossy())
.unwrap_or_default()
})
.take(5)
.join("\n");
if to_delete.len() > 5 {
details.push_str(&format!("\nand {} more…", to_delete.len() - 5))
}
let prompt = prompt("Trash these files?", Some(&details), window, cx);
cx.spawn_in(window, |this, mut cx| async move {
match prompt.await? {