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_graph: Allow cancelling active selection via keyboard (#49836)

Remco Smits1240fd1f361f
diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs
index ad6aa7ec3c6..a8318e5122f 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>) {
+ self.selected_entry_idx = None;
+ self.selected_commit_diff = None;
+ cx.notify();
+ }
+
fn select_prev(&mut self, _: &SelectPrevious, _window: &mut Window, cx: &mut Context<Self>) {
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)