From 878b50c991042b876f1fb67f5c76619cbca2170c Mon Sep 17 00:00:00 2001 From: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> Date: Thu, 27 Feb 2025 00:29:26 -0500 Subject: [PATCH] Update git panel entry checked box tooltip to say Stage/Unstage (#25678) Before it would always say staged when a user hovered over the check box. Now it will show the correct hover message depending on the state of the entry Release Notes: - N/A --- crates/git_ui/src/git_panel.rs | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index edc91b9db85d342bc3775f3547e8fd025cec3810..c541e87133666f77c8bd8062c07f279037970450 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -2488,6 +2488,7 @@ impl GitPanel { let id: ElementId = ElementId::Name(format!("entry_{}", display_name).into()); + let is_entry_staged = self.entry_is_staged(entry); let mut is_staged: ToggleState = self.entry_is_staged(entry).into(); if !self.has_staged_changes() && !self.has_conflicts() && !entry.status.is_created() { @@ -2511,18 +2512,23 @@ impl GitPanel { }) }); - let start_slot = - h_flex() - .id(("start-slot", ix)) - .gap(DynamicSpacing::Base04.rems(cx)) - .child(checkbox.tooltip(|window, cx| { - Tooltip::for_action("Stage File", &ToggleStaged, window, cx) - })) - .child(git_status_icon(status, cx)) - .on_mouse_down(MouseButton::Left, |_, _, cx| { - // prevent the list item active state triggering when toggling checkbox - cx.stop_propagation(); - }); + let start_slot = h_flex() + .id(("start-slot", ix)) + .gap(DynamicSpacing::Base04.rems(cx)) + .child(checkbox.tooltip(move |window, cx| { + let tooltip_name = if is_entry_staged.unwrap_or(false) { + "Unstage" + } else { + "Stage" + }; + + Tooltip::for_action(tooltip_name, &ToggleStaged, window, cx) + })) + .child(git_status_icon(status, cx)) + .on_mouse_down(MouseButton::Left, |_, _, cx| { + // prevent the list item active state triggering when toggling checkbox + cx.stop_propagation(); + }); div() .w_full()