From 4f98157e64709c3fd8fa91914ad0ebbcb9d6c6a9 Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Tue, 4 Feb 2025 14:45:45 -0300 Subject: [PATCH] edit predictions: Make Zed bar at least as wide as menu (#24206) Release Notes: - N/A --------- Co-authored-by: Ben --- crates/editor/src/editor.rs | 12 +++++++++--- crates/editor/src/element.rs | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cad517599feea2a81868ca9a90e4facdd9b15295..a9469345322c9e95815892fe3b5fe4714d15dbdf 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5415,6 +5415,7 @@ impl Editor { #[allow(clippy::too_many_arguments)] fn render_edit_prediction_cursor_popover( &self, + min_width: Pixels, max_width: Pixels, cursor_point: Point, line_layouts: &[LineWithInvisibles], @@ -5429,6 +5430,7 @@ impl Editor { return Some( h_flex() .h(self.edit_prediction_cursor_popover_height()) + .min_w(min_width) .flex_1() .px_2() .gap_3() @@ -5458,7 +5460,10 @@ impl Editor { let is_refreshing = provider.provider.is_refreshing(cx); fn pending_completion_container() -> Div { - h_flex().gap_3().child(Icon::new(IconName::ZedPredict)) + h_flex() + .flex_1() + .gap_3() + .child(Icon::new(IconName::ZedPredict)) } let completion = match &self.active_inline_completion { @@ -5509,13 +5514,13 @@ impl Editor { Some( h_flex() .h(self.edit_prediction_cursor_popover_height()) + .min_w(min_width) .max_w(max_width) .flex_1() .px_2() .gap_3() .elevation_2(cx) .child(completion) - .child(div().w_full()) .child( h_flex() .border_l_1() @@ -5648,7 +5653,7 @@ impl Editor { Icon::new(IconName::ZedPredict).into_any_element() }; - Some(h_flex().gap_3().child(left).child(preview)) + Some(h_flex().flex_1().gap_3().child(left).child(preview)) } InlineCompletion::Move { @@ -5681,6 +5686,7 @@ impl Editor { Some( h_flex() .gap_3() + .flex_1() .child(render_relative_row_jump( "Jump ", cursor_point.row, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index d81ad1441553c6afa1b4d493592c1b8fbe493f22..7af416ba0528e76685c64b9b5f79538aeb367548 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3241,11 +3241,15 @@ impl EditorElement { } else { None }; + let min_width = context_menu + .as_ref() + .map_or(px(0.), |(_, _, size)| size.width); let max_width = max_width_for_stable_x.max( context_menu .as_ref() .map_or(px(0.), |(_, _, size)| size.width), ); + let edit_prediction = if edit_prediction_popover_visible { let accept_keystroke: Option; @@ -3299,6 +3303,7 @@ impl EditorElement { self.editor.update(cx, move |editor, cx| { let mut element = editor.render_edit_prediction_cursor_popover( + min_width, max_width, cursor_point, &line_layouts,