From 1903a29cca012e68431d96adb13fe8f2fb6a03ac Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Fri, 29 Nov 2024 12:38:12 -0300
Subject: [PATCH] Expose "Column Git Blame" in the editor controls menu
(#21336)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes https://github.com/zed-industries/zed/issues/10196
I think having this action exposed in the editor controls menu, close to
the inline Git Blame option, makes more sense than a more prominent item
somewhere else in the app. Maybe having it there will increase its
discoverability. I myself didn't know this until a few weeks ago! Next
steps would be ensuring the menu exposes its keybindings.
(Quick note about the menu item name: I think maybe "_Git Blame Column_"
would make more sense and feel grammatically more correct, but then we
would have two Git Blame-related options, one with "Git Blame" at the
start (Inline...) and another with "Git Blame" at the end (... Column).
I guess one had to be sacrificed for the sake of consistency 😅.)
Release Notes:
- N/A
---
assets/icons/cursor_i_beam.svg | 6 ++-
crates/editor/src/editor.rs | 4 ++
crates/zed/src/zed/quick_action_bar.rs | 57 ++++++++++++++++++--------
3 files changed, 49 insertions(+), 18 deletions(-)
diff --git a/assets/icons/cursor_i_beam.svg b/assets/icons/cursor_i_beam.svg
index 2e7b95b2039455f8a5154af2dc496bbab31d2e52..93ac068fe2a8543a70941ae864b7acbdeb4bb995 100644
--- a/assets/icons/cursor_i_beam.svg
+++ b/assets/icons/cursor_i_beam.svg
@@ -1 +1,5 @@
-
+
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 24ae84b0350003034a40c7de734e027e0a2298d0..6e729a654d06ed9866da02038562b6550171abd3 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 85090a1b979fb9a8a62bd758536445bd09ba14bf..bfcd3fa39122d923d3408c1f549d1ddf4ed43776 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();
}