Skip to content

Commit

Permalink
First check if menu visible in layout_gutter_menu (#24259)
Browse files Browse the repository at this point in the history
Also uses an expect instead of unwrap for result of
`render_context_menu`

Release Notes:

- N/A
  • Loading branch information
mgsloan authored Feb 6, 2025
1 parent c61f12d commit 10792ee
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3170,7 +3170,7 @@ impl EditorElement {
};
let mut element = self
.render_context_menu(line_height, menu_height, y_flipped, window, cx)
.unwrap();
.expect("Visible context menu should always render.");
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
Some((CursorPopoverType::CodeContextMenu, element, size))
} else {
Expand Down Expand Up @@ -3328,8 +3328,12 @@ impl EditorElement {
window: &mut Window,
cx: &mut App,
) {
let editor = self.editor.read(cx);
if !editor.context_menu_visible() {
return;
}
let Some(crate::ContextMenuOrigin::GutterIndicator(gutter_row)) =
self.editor.read(cx).context_menu_origin()
editor.context_menu_origin()
else {
return;
};
Expand Down Expand Up @@ -3357,11 +3361,9 @@ impl EditorElement {
window,
cx,
move |height, _max_width_for_stable_x, y_flipped, window, cx| {
let Some(mut element) =
self.render_context_menu(line_height, height, y_flipped, window, cx)
else {
return vec![];
};
let mut element = self
.render_context_menu(line_height, height, y_flipped, window, cx)
.expect("Visible context menu should always render.");
let size = element.layout_as_root(AvailableSpace::min_size(), window, cx);
vec![(CursorPopoverType::CodeContextMenu, element, size)]
},
Expand Down

0 comments on commit 10792ee

Please sign in to comment.