Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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> {
Expand All @@ -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);
Expand Down
Loading