diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs index ad6aa7ec3c6f9a129495e437bd379b023ec7cf61..a8318e5122f7f37b00ee9a2d966b387282c8073d 100644 --- a/crates/git_graph/src/git_graph.rs +++ b/crates/git_graph/src/git_graph.rs @@ -13,7 +13,7 @@ use gpui::{ ScrollWheelEvent, SharedString, Styled, Subscription, Task, WeakEntity, Window, actions, anchored, deferred, point, px, }; -use menu::{SelectNext, SelectPrevious}; +use menu::{Cancel, SelectNext, SelectPrevious}; use project::{ Project, git_store::{CommitDataState, GitStoreEvent, Repository, RepositoryEvent, RepositoryId}, @@ -936,6 +936,12 @@ impl GitGraph { .collect() } + fn cancel(&mut self, _: &Cancel, _window: &mut Window, cx: &mut Context) { + self.selected_entry_idx = None; + self.selected_commit_diff = None; + cx.notify(); + } + fn select_prev(&mut self, _: &SelectPrevious, _window: &mut Window, cx: &mut Context) { if let Some(selected_entry_idx) = &self.selected_entry_idx { self.select_entry(selected_entry_idx.saturating_sub(1), cx); @@ -1804,6 +1810,7 @@ impl Render for GitGraph { .on_action(cx.listener(|this, _: &OpenCommitView, window, cx| { this.open_selected_commit_view(window, cx); })) + .on_action(cx.listener(Self::cancel)) .on_action(cx.listener(Self::select_prev)) .on_action(cx.listener(Self::select_next)) .child(content)