Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Conrad Irwindd1ff9b99863
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index 8f83f793bb7..9266c05f5dd 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -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? {