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.

editor: Add the git blame toggle to gutter context menu (#59460)

( Nechiforel David-Samuel ) NsdHSO0a2f8b5b5c1c
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index e165c765f26..e98defa3085 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -128,7 +128,7 @@ pub use split::{SplittableEditor, ToggleSplitDiff};
pub use split_editor_view::SplitEditorView;
pub use text::Bias;
-use ::git::status::FileStatus;
+use ::git::{Blame, status::FileStatus};
use aho_corasick::{AhoCorasick, AhoCorasickBuilder, BuildError};
use anyhow::{Context as _, Result, anyhow, bail};
use blink_manager::BlinkManager;
@@ -4087,6 +4087,12 @@ impl Editor {
"Set Breakpoint"
};
+ let git_blame_msg = if self.show_git_blame_gutter {
+ "Close Git Blame"
+ } else {
+ "Open Git Blame"
+ };
+
let bookmark = self.bookmark_at_row(row, window, cx);
let set_bookmark_msg = if bookmark.as_ref().is_some() {
@@ -4233,17 +4239,24 @@ impl Editor {
}
})
.separator()
- .entry(
- set_bookmark_msg,
- Some(ToggleBookmark.boxed_clone()),
- move |_window, cx| {
+ .entry(git_blame_msg, Some(Blame.boxed_clone()), {
+ let weak_editor = weak_editor.clone();
+ move |window, cx| {
weak_editor
.update(cx, |this, cx| {
- this.toggle_bookmark_at_anchor(anchor, cx);
+ this.toggle_git_blame(&Blame, window, cx);
})
.log_err();
- },
- )
+ }
+ })
+ .separator()
+ .entry(set_bookmark_msg, None, move |_window, cx| {
+ weak_editor
+ .update(cx, |this, cx| {
+ this.toggle_bookmark_at_anchor(anchor, cx);
+ })
+ .log_err();
+ })
})
}