From a5c5dd09129d7486eee1891bce0618dc16da7ddc Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Thu, 23 Apr 2026 17:21:45 -0400 Subject: [PATCH] Adjust UI for gutter right-click menus (again) (#54710) - #54632 unintentionally reverted changes introduced in #54681, likely due to a merge conflict resolution issue. See the original PR for the changes. Release Notes: - N/A Co-authored-by: Danilo Leal --- assets/icons/bookmark.svg | 3 +-- crates/editor/src/editor.rs | 50 ++++++++++++++++++++---------------- crates/editor/src/element.rs | 3 +++ 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/assets/icons/bookmark.svg b/assets/icons/bookmark.svg index 999c9b72a1..50914b2933 100644 --- a/assets/icons/bookmark.svg +++ b/assets/icons/bookmark.svg @@ -1,4 +1,3 @@ - - + diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b01d1592ab..7911b036fc 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -9258,9 +9258,9 @@ impl Editor { })) .tooltip(move |_window, cx| { Tooltip::with_meta_in( - "Remove bookmark", + "Remove Bookmark", Some(&ToggleBookmark), - SharedString::from("Right-click for more options."), + SharedString::from("Right-click for more options"), &focus_handle, cx, ) @@ -9546,15 +9546,16 @@ impl Editor { }; let primary_action_text = "Unset breakpoint"; let focus_handle = self.focus_handle.clone(); + let has_context_menu = self.has_mouse_context_menu(); let meta = if is_rejected { SharedString::from("No executable code is associated with this line.") } else if !breakpoint.is_disabled() { SharedString::from(format!( - "{alt_as_text}click to disable,\nright-click for more options." + "{alt_as_text}-click to disable\nright-click for more options" )) } else { - SharedString::from("Right-click for more options.") + SharedString::from("Right-click for more options") }; IconButton::new(("breakpoint_indicator", row.0 as usize), icon) .icon_size(IconSize::XSmall) @@ -9584,14 +9585,16 @@ impl Editor { .on_right_click(cx.listener(move |editor, event: &ClickEvent, window, cx| { editor.set_gutter_context_menu(row, Some(position), event.position(), window, cx); })) - .tooltip(move |_window, cx| { - Tooltip::with_meta_in( - primary_action_text, - Some(&ToggleBreakpoint), - meta.clone(), - &focus_handle, - cx, - ) + .when(!has_context_menu, |button| { + button.tooltip(move |_window, cx| { + Tooltip::with_meta_in( + primary_action_text, + Some(&ToggleBreakpoint), + meta.clone(), + &focus_handle, + cx, + ) + }) }) } @@ -9637,10 +9640,10 @@ impl Editor { }; match self { Intent::SetBookmark => format!( - "{alt_as_text}click to add a breakpoint,\nright-click for more options." + "{alt_as_text}-click to add a breakpoint\nright-click for more options" ), Intent::SetBreakpoint => format!( - "{alt_as_text}click to add a bookmark,\nright-click for more options." + "{alt_as_text}-click to add a bookmark\nright-click for more options" ), } } @@ -9667,6 +9670,7 @@ impl Editor { }; let focus_handle = self.focus_handle.clone(); + let has_context_menu = self.has_mouse_context_menu(); IconButton::new(("add_breakpoint_button", row.0 as usize), intent.icon()) .icon_size(IconSize::XSmall) .size(ui::ButtonSize::None) @@ -9695,14 +9699,16 @@ impl Editor { .on_right_click(cx.listener(move |editor, event: &ClickEvent, window, cx| { editor.set_gutter_context_menu(row, Some(position), event.position(), window, cx); })) - .tooltip(move |_window, cx| { - Tooltip::with_meta_in( - intent.as_str(), - Some(&ToggleBreakpoint), - intent.secondary_and_options(), - &focus_handle, - cx, - ) + .when(!has_context_menu, |button| { + button.tooltip(move |_window, cx| { + Tooltip::with_meta_in( + intent.as_str(), + Some(&ToggleBreakpoint), + intent.secondary_and_options(), + &focus_handle, + cx, + ) + }) }) } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 0646bf7a06..7ee76a02b9 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1439,6 +1439,9 @@ impl EditorElement { editor.gutter_hover_button.1 = None; None } + } else if editor.has_mouse_context_menu() { + editor.gutter_hover_button.1 = None; + editor.gutter_hover_button.0 } else { editor.gutter_hover_button.1 = None; None