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.

Fix "Loading Commit History..." message stuck on empty repositories (#58649)

Jeremy-Qianf56e78266167
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index b2f9f9cf1b3..c0e9b04614a 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -5131,15 +5131,36 @@ impl GitPanel {
fn render_history_tab(&self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
v_flex().flex_1().size_full().overflow_hidden().map(|this| {
- if let Some(history) = self.render_commit_history(window, cx) {
- this.child(history)
- } else {
+ let has_repo = self.active_repository.is_some();
+ let has_commits = self
+ .commit_history_shas
+ .as_ref()
+ .map_or(false, |shas| !shas.is_empty());
+ let is_loading = self.commit_history_shas.is_none() && has_repo;
+ if is_loading {
this.child(
h_flex()
.flex_1()
.justify_center()
.child(Label::new("Loading Commit History…").color(Color::Muted)),
)
+ } else if !has_repo || !has_commits {
+ this.child(
+ h_flex()
+ .flex_1()
+ .justify_center()
+ .child(Label::new("No commits yet").color(Color::Muted)),
+ )
+ } else {
+ match self.render_commit_history(window, cx) {
+ Some(history) => this.child(history),
+ None => this.child(
+ h_flex()
+ .flex_1()
+ .justify_center()
+ .child(Label::new("Failed to load commits").color(Color::Muted)),
+ ),
+ }
}
})
}