mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-31 19:05:00 +07:00
git_ui: Fix stale loading message in git history pane
This commit is contained in:
parent
b7b1d1a2c7
commit
e50190386c
1 changed files with 9 additions and 13 deletions
|
|
@ -697,7 +697,7 @@ pub struct GitPanel {
|
|||
stash_entries: GitStash,
|
||||
active_tab: GitPanelTab,
|
||||
commit_history_scroll_handle: UniformListScrollHandle,
|
||||
commit_history_shas: Vec<Oid>,
|
||||
commit_history_shas: Option<Vec<Oid>>,
|
||||
focused_history_entry: Option<usize>,
|
||||
history_keyboard_nav: bool,
|
||||
_repo_subscriptions: Vec<Subscription>,
|
||||
|
|
@ -894,7 +894,7 @@ impl GitPanel {
|
|||
stash_entries: Default::default(),
|
||||
active_tab: GitPanelTab::Changes,
|
||||
commit_history_scroll_handle: UniformListScrollHandle::new(),
|
||||
commit_history_shas: Vec::new(),
|
||||
commit_history_shas: None,
|
||||
focused_history_entry: None,
|
||||
history_keyboard_nav: false,
|
||||
_repo_subscriptions: Vec::new(),
|
||||
|
|
@ -5134,7 +5134,7 @@ impl GitPanel {
|
|||
}
|
||||
|
||||
fn select_next_history_entry(&mut self, cx: &mut Context<Self>) {
|
||||
let count = self.commit_history_shas.len();
|
||||
let count = self.commit_history_shas.as_ref().map_or(0, Vec::len);
|
||||
if count == 0 {
|
||||
return;
|
||||
}
|
||||
|
|
@ -5150,7 +5150,7 @@ impl GitPanel {
|
|||
}
|
||||
|
||||
fn select_previous_history_entry(&mut self, cx: &mut Context<Self>) {
|
||||
let count = self.commit_history_shas.len();
|
||||
let count = self.commit_history_shas.as_ref().map_or(0, Vec::len);
|
||||
if count == 0 {
|
||||
return;
|
||||
}
|
||||
|
|
@ -5169,7 +5169,7 @@ impl GitPanel {
|
|||
let Some(index) = self.focused_history_entry else {
|
||||
return;
|
||||
};
|
||||
let Some(sha) = self.commit_history_shas.get(index) else {
|
||||
let Some(sha) = self.commit_history_shas.as_ref().and_then(|s| s.get(index)) else {
|
||||
return;
|
||||
};
|
||||
let Some(active_repository) = self.active_repository.as_ref() else {
|
||||
|
|
@ -5217,7 +5217,7 @@ impl GitPanel {
|
|||
}
|
||||
GitPanelTab::Changes => {
|
||||
self.focus_handle.focus(window, cx);
|
||||
self.commit_history_shas.clear();
|
||||
self.commit_history_shas.take();
|
||||
self.focused_history_entry = None;
|
||||
self._repo_subscriptions.clear();
|
||||
}
|
||||
|
|
@ -5283,10 +5283,10 @@ impl GitPanel {
|
|||
let log_source = LogSource::Branch(branch_name.into());
|
||||
let log_order = LogOrder::DateOrder;
|
||||
|
||||
self.commit_history_shas = active_repository.update(cx, |repository, cx| {
|
||||
self.commit_history_shas = Some(active_repository.update(cx, |repository, cx| {
|
||||
let response = repository.graph_data(log_source, log_order, 0..usize::MAX, cx);
|
||||
response.commits.iter().map(|commit| commit.sha).collect()
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
fn git_remote(&self, cx: &mut App) -> Option<GitRemote> {
|
||||
|
|
@ -5306,14 +5306,10 @@ impl GitPanel {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<impl IntoElement> {
|
||||
if self.commit_history_shas.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let shas = self.commit_history_shas.clone()?;
|
||||
let active_repository = self.active_repository.as_ref()?;
|
||||
let workspace = self.workspace.clone();
|
||||
let repo_weak = active_repository.downgrade();
|
||||
let shas = self.commit_history_shas.clone();
|
||||
let item_count = shas.len();
|
||||
let commit_history_scroll_handle = self.commit_history_scroll_handle.clone();
|
||||
let remote = self.git_remote(cx);
|
||||
|
|
|
|||
Loading…
Reference in a new issue