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_ui: Disable commit actions during commit message generation (#51727)

Xiaobo Liuaa0923404f69
diff --git a/crates/git_ui/src/commit_modal.rs b/crates/git_ui/src/commit_modal.rs
index 06c554e7b6e..7ba5558dd95 100644
--- a/crates/git_ui/src/commit_modal.rs
+++ b/crates/git_ui/src/commit_modal.rs
@@ -268,15 +268,19 @@ impl CommitModal {
&self,
id: impl Into<ElementId>,
keybinding_target: Option<FocusHandle>,
+ disabled: bool,
) -> impl IntoElement {
let menu_open = self.commit_menu_handle.is_deployed();
PopoverMenu::new(id.into())
.with_handle(self.commit_menu_handle.clone())
- .trigger(crate::render_split_button_chevron_trigger(
- "modal-commit-split-button-right",
- menu_open,
- ))
+ .trigger(
+ crate::render_split_button_chevron_trigger(
+ "modal-commit-split-button-right",
+ menu_open,
+ )
+ .disabled(disabled),
+ )
.menu({
let git_panel_entity = self.git_panel.clone();
move |window, cx| {
@@ -343,6 +347,7 @@ impl CommitModal {
is_amend_pending,
is_signoff_enabled,
workspace,
+ is_generating,
) = self.git_panel.update(cx, |git_panel, cx| {
let (can_commit, tooltip) = git_panel.configure_commit_button(cx);
let title = git_panel.commit_button_title();
@@ -351,6 +356,7 @@ impl CommitModal {
let active_repo = git_panel.active_repository.clone();
let is_amend_pending = git_panel.amend_pending();
let is_signoff_enabled = git_panel.signoff_enabled();
+ let is_generating = git_panel.is_generating_commit_message();
(
can_commit,
tooltip,
@@ -361,6 +367,7 @@ impl CommitModal {
is_amend_pending,
is_signoff_enabled,
git_panel.workspace.clone(),
+ is_generating,
)
});
@@ -478,6 +485,7 @@ impl CommitModal {
self.render_git_commit_menu(
format!("split-button-right-{}", commit_label),
Some(focus_handle),
+ is_generating,
)
.into_any_element(),
)),
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index d7021e1b51b..36d07381d81 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -5344,15 +5344,16 @@ impl GitPanel {
&self,
id: impl Into<ElementId>,
keybinding_target: Option<FocusHandle>,
+ disabled: bool,
cx: &mut Context<Self>,
) -> impl IntoElement {
let menu_open = self.commit_menu_handle.is_deployed();
PopoverMenu::new(id.into())
- .trigger(crate::render_split_button_chevron_trigger(
- "commit-split-button-right",
- menu_open,
- ))
+ .trigger(
+ crate::render_split_button_chevron_trigger("commit-split-button-right", menu_open)
+ .disabled(disabled),
+ )
.with_handle(self.commit_menu_handle.clone())
.menu({
let git_panel = cx.entity();
@@ -5401,8 +5402,14 @@ impl GitPanel {
})
}
+ pub fn is_generating_commit_message(&self) -> bool {
+ self.generate_commit_message_task.is_some()
+ }
+
pub fn configure_commit_button(&self, cx: &mut Context<Self>) -> (bool, &'static str) {
- if self.has_unstaged_conflicts() {
+ if self.generate_commit_message_task.is_some() {
+ (false, "Generating commit message...")
+ } else if self.has_unstaged_conflicts() {
(false, "You must resolve conflicts before committing")
} else if !self.has_staged_changes() && !self.has_tracked_changes() && !self.amend_pending {
(false, "No changes to commit")
@@ -5896,6 +5903,7 @@ impl GitPanel {
self.render_git_commit_menu(
ElementId::Name(format!("split-button-right-{}", title).into()),
Some(commit_tooltip_focus_handle),
+ self.generate_commit_message_task.is_some(),
cx,
)
.into_any_element(),