edit predictions: Make Zed bar at least as wide as menu (#24206)

Release Notes:

- N/A

---------

Co-authored-by: Ben <ben@zed.dev>
This commit is contained in:
Agus Zubiaga 2025-02-04 14:45:45 -03:00 committed by GitHub
parent 9b031d747f
commit 4f98157e64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View file

@ -5415,6 +5415,7 @@ impl Editor {
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
fn render_edit_prediction_cursor_popover( fn render_edit_prediction_cursor_popover(
&self, &self,
min_width: Pixels,
max_width: Pixels, max_width: Pixels,
cursor_point: Point, cursor_point: Point,
line_layouts: &[LineWithInvisibles], line_layouts: &[LineWithInvisibles],
@ -5429,6 +5430,7 @@ impl Editor {
return Some( return Some(
h_flex() h_flex()
.h(self.edit_prediction_cursor_popover_height()) .h(self.edit_prediction_cursor_popover_height())
.min_w(min_width)
.flex_1() .flex_1()
.px_2() .px_2()
.gap_3() .gap_3()
@ -5458,7 +5460,10 @@ impl Editor {
let is_refreshing = provider.provider.is_refreshing(cx); let is_refreshing = provider.provider.is_refreshing(cx);
fn pending_completion_container() -> Div { 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 { let completion = match &self.active_inline_completion {
@ -5509,13 +5514,13 @@ impl Editor {
Some( Some(
h_flex() h_flex()
.h(self.edit_prediction_cursor_popover_height()) .h(self.edit_prediction_cursor_popover_height())
.min_w(min_width)
.max_w(max_width) .max_w(max_width)
.flex_1() .flex_1()
.px_2() .px_2()
.gap_3() .gap_3()
.elevation_2(cx) .elevation_2(cx)
.child(completion) .child(completion)
.child(div().w_full())
.child( .child(
h_flex() h_flex()
.border_l_1() .border_l_1()
@ -5648,7 +5653,7 @@ impl Editor {
Icon::new(IconName::ZedPredict).into_any_element() 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 { InlineCompletion::Move {
@ -5681,6 +5686,7 @@ impl Editor {
Some( Some(
h_flex() h_flex()
.gap_3() .gap_3()
.flex_1()
.child(render_relative_row_jump( .child(render_relative_row_jump(
"Jump ", "Jump ",
cursor_point.row, cursor_point.row,

View file

@ -3241,11 +3241,15 @@ impl EditorElement {
} else { } else {
None None
}; };
let min_width = context_menu
.as_ref()
.map_or(px(0.), |(_, _, size)| size.width);
let max_width = max_width_for_stable_x.max( let max_width = max_width_for_stable_x.max(
context_menu context_menu
.as_ref() .as_ref()
.map_or(px(0.), |(_, _, size)| size.width), .map_or(px(0.), |(_, _, size)| size.width),
); );
let edit_prediction = if edit_prediction_popover_visible { let edit_prediction = if edit_prediction_popover_visible {
let accept_keystroke: Option<Keystroke>; let accept_keystroke: Option<Keystroke>;
@ -3299,6 +3303,7 @@ impl EditorElement {
self.editor.update(cx, move |editor, cx| { self.editor.update(cx, move |editor, cx| {
let mut element = editor.render_edit_prediction_cursor_popover( let mut element = editor.render_edit_prediction_cursor_popover(
min_width,
max_width, max_width,
cursor_point, cursor_point,
&line_layouts, &line_layouts,