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.

Expose "Column Git Blame" in the editor controls menu (#21336)

Danilo Leal1903a29cca01
diff --git a/assets/icons/cursor_i_beam.svg b/assets/icons/cursor_i_beam.svg
index 2e7b95b2039..93ac068fe2a 100644
--- a/assets/icons/cursor_i_beam.svg
+++ b/assets/icons/cursor_i_beam.svg
@@ -1 +1,5 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text-cursor"><path d="M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1"/><path d="M7 22h1a4 4 0 0 0 4-4v-1"/><path d="M7 2h1a4 4 0 0 1 4 4v1"/></svg>
+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M17 20H16C14.9391 20 13.9217 19.6629 13.1716 19.0627C12.4214 18.4626 12 17.6487 12 16.8V7.2C12 6.35131 12.4214 5.53737 13.1716 4.93726C13.9217 4.33714 14.9391 4 16 4H17" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7 20H8C9.06087 20 10.0783 19.5786 10.8284 18.8284C11.5786 18.0783 12 17.0609 12 16V15" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7 4H8C9.06087 4 10.0783 4.42143 10.8284 5.17157C11.5786 5.92172 12 6.93913 12 8V9" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 24ae84b0350..6e729a654d0 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -11796,6 +11796,10 @@ impl Editor {
self.blame.as_ref()
}
+ pub fn show_git_blame_gutter(&self) -> bool {
+ self.show_git_blame_gutter
+ }
+
pub fn render_git_blame_gutter(&mut self, cx: &mut WindowContext) -> bool {
self.show_git_blame_gutter && self.has_blame_entries(cx)
}
diff --git a/crates/zed/src/zed/quick_action_bar.rs b/crates/zed/src/zed/quick_action_bar.rs
index 85090a1b979..bfcd3fa3912 100644
--- a/crates/zed/src/zed/quick_action_bar.rs
+++ b/crates/zed/src/zed/quick_action_bar.rs
@@ -91,6 +91,7 @@ impl Render for QuickActionBar {
inlay_hints_enabled,
supports_inlay_hints,
git_blame_inline_enabled,
+ show_git_blame_gutter,
auto_signature_help_enabled,
) = {
let editor = editor.read(cx);
@@ -98,6 +99,7 @@ impl Render for QuickActionBar {
let inlay_hints_enabled = editor.inlay_hints_enabled();
let supports_inlay_hints = editor.supports_inlay_hints(cx);
let git_blame_inline_enabled = editor.git_blame_inline_enabled();
+ let show_git_blame_gutter = editor.show_git_blame_gutter();
let auto_signature_help_enabled = editor.auto_signature_help_enabled(cx);
(
@@ -105,6 +107,7 @@ impl Render for QuickActionBar {
inlay_hints_enabled,
supports_inlay_hints,
git_blame_inline_enabled,
+ show_git_blame_gutter,
auto_signature_help_enabled,
)
};
@@ -236,17 +239,17 @@ impl Render for QuickActionBar {
}
menu = menu.toggleable_entry(
- "Inline Git Blame",
- git_blame_inline_enabled,
+ "Selection Menu",
+ selection_menu_enabled,
IconPosition::Start,
- Some(editor::actions::ToggleGitBlameInline.boxed_clone()),
+ Some(editor::actions::ToggleSelectionMenu.boxed_clone()),
{
let editor = editor.clone();
move |cx| {
editor
.update(cx, |editor, cx| {
- editor.toggle_git_blame_inline(
- &editor::actions::ToggleGitBlameInline,
+ editor.toggle_selection_menu(
+ &editor::actions::ToggleSelectionMenu,
cx,
)
})
@@ -256,39 +259,59 @@ impl Render for QuickActionBar {
);
menu = menu.toggleable_entry(
- "Selection Menu",
- selection_menu_enabled,
+ "Auto Signature Help",
+ auto_signature_help_enabled,
IconPosition::Start,
- Some(editor::actions::ToggleSelectionMenu.boxed_clone()),
+ Some(editor::actions::ToggleAutoSignatureHelp.boxed_clone()),
{
let editor = editor.clone();
move |cx| {
editor
.update(cx, |editor, cx| {
- editor.toggle_selection_menu(
- &editor::actions::ToggleSelectionMenu,
+ editor.toggle_auto_signature_help_menu(
+ &editor::actions::ToggleAutoSignatureHelp,
cx,
- )
+ );
})
.ok();
}
},
);
+ menu = menu.separator();
+
menu = menu.toggleable_entry(
- "Auto Signature Help",
- auto_signature_help_enabled,
+ "Inline Git Blame",
+ git_blame_inline_enabled,
IconPosition::Start,
- Some(editor::actions::ToggleAutoSignatureHelp.boxed_clone()),
+ Some(editor::actions::ToggleGitBlameInline.boxed_clone()),
{
let editor = editor.clone();
move |cx| {
editor
.update(cx, |editor, cx| {
- editor.toggle_auto_signature_help_menu(
- &editor::actions::ToggleAutoSignatureHelp,
+ editor.toggle_git_blame_inline(
+ &editor::actions::ToggleGitBlameInline,
cx,
- );
+ )
+ })
+ .ok();
+ }
+ },
+ );
+
+ menu = menu.toggleable_entry(
+ "Column Git Blame",
+ show_git_blame_gutter,
+ IconPosition::Start,
+ Some(editor::actions::ToggleGitBlame.boxed_clone()),
+ {
+ let editor = editor.clone();
+ move |cx| {
+ editor
+ .update(cx, |editor, cx| {
+ editor
+ .toggle_git_blame(&editor::actions::ToggleGitBlame, cx)
})
.ok();
}