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.

Adjust UI for gutter right-click menus (again) (#54710)

Joseph T. Lyonsa5c5dd09129d
diff --git a/assets/icons/bookmark.svg b/assets/icons/bookmark.svg
index 999c9b72a1e..50914b29335 100644
--- a/assets/icons/bookmark.svg
+++ b/assets/icons/bookmark.svg
@@ -1,4 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
-<path d="M11.0885 2.44067C11.4162 2.44067 11.7304 2.57083 11.9621 2.80251C12.1938 3.0342 12.3239 3.34843 12.3239 3.67607V12.9416C12.3239 13.0498 12.2954 13.156 12.2414 13.2497C12.1874 13.3435 12.1098 13.4214 12.0162 13.4757C11.9227 13.53 11.8165 13.5587 11.7083 13.5591C11.6001 13.5594 11.4938 13.5314 11.3998 13.4777L8.61278 11.8853C8.42615 11.7787 8.21495 11.7226 8.00002 11.7226C7.78509 11.7226 7.57389 11.7787 7.38726 11.8853L4.6002 13.4777C4.50627 13.5314 4.3999 13.5594 4.29173 13.5591C4.18356 13.5587 4.07738 13.53 3.98382 13.4757C3.89026 13.4214 3.81259 13.3435 3.75859 13.2497C3.70459 13.156 3.67615 13.0498 3.67612 12.9416V3.67607C3.67612 3.34843 3.80627 3.0342 4.03796 2.80251C4.26964 2.57083 4.58387 2.44067 4.91152 2.44067H11.0885Z" stroke="#C6CAD0" stroke-width="1.11186" stroke-linecap="round" stroke-linejoin="round"/>
-<path opacity="0.12" d="M11.0885 2.44067C11.4162 2.44067 11.7304 2.57083 11.9621 2.80251C12.1938 3.0342 12.3239 3.34843 12.3239 3.67607V12.9416C12.3239 13.0498 12.2954 13.156 12.2414 13.2497C12.1874 13.3435 12.1098 13.4214 12.0162 13.4757C11.9227 13.53 11.8165 13.5587 11.7083 13.5591C11.6001 13.5594 11.4938 13.5314 11.3998 13.4777L8.61278 11.8853C8.42615 11.7787 8.21495 11.7226 8.00002 11.7226C7.78509 11.7226 7.57389 11.7787 7.38726 11.8853L4.6002 13.4777C4.50627 13.5314 4.3999 13.5594 4.29173 13.5591C4.18356 13.5587 4.07738 13.53 3.98382 13.4757C3.89026 13.4214 3.81259 13.3435 3.75859 13.2497C3.70459 13.156 3.67615 13.0498 3.67612 12.9416V3.67607C3.67612 3.34843 3.80627 3.0342 4.03796 2.80251C4.26964 2.57083 4.58387 2.44067 4.91152 2.44067H11.0885Z" fill="#C6CAD0" stroke="#C6CAD0" stroke-width="1.11186" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M11.8644 1.04416C12.2744 1.04416 12.6675 1.20702 12.9574 1.4969C13.2473 1.78679 13.4101 2.17996 13.4101 2.5899V14.183C13.4101 14.3184 13.3744 14.4513 13.3069 14.5685C13.2393 14.6859 13.1422 14.7833 13.0251 14.8513C12.9081 14.9192 12.7752 14.9551 12.6399 14.9556C12.5045 14.956 12.3715 14.921 12.2539 14.8538L8.76673 12.8614C8.53321 12.728 8.26896 12.6578 8.00004 12.6578C7.73111 12.6578 7.46686 12.728 7.23334 12.8614L3.74615 14.8538C3.62863 14.921 3.49553 14.956 3.36019 14.9556C3.22485 14.9551 3.092 14.9192 2.97493 14.8513C2.85787 14.7833 2.76069 14.6859 2.69312 14.5685C2.62556 14.4513 2.58997 14.3184 2.58994 14.183V2.5899C2.58994 2.17996 2.75278 1.78679 3.04267 1.4969C3.33255 1.20702 3.72572 1.04416 4.13568 1.04416H11.8644Z" fill="#C6CAD0"/>
</svg>
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index b01d1592abb..7911b036fc1 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 0646bf7a068..7ee76a02b96 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