Align the inline assistant correctly (#12478)

Release Notes:

- Fixed the the alignment for the inline assistant.
This commit is contained in:
Antonio Scandurra 2024-05-30 14:29:17 +02:00 committed by GitHub
parent 6ff01b17ca
commit 55c47305c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -447,8 +447,8 @@ impl AssistantPanel {
let inline_assistant = inline_assistant.clone(); let inline_assistant = inline_assistant.clone();
move |cx: &mut BlockContext| { move |cx: &mut BlockContext| {
*measurements.lock() = BlockMeasurements { *measurements.lock() = BlockMeasurements {
anchor_x: cx.anchor_x,
gutter_width: cx.gutter_dimensions.width, gutter_width: cx.gutter_dimensions.width,
gutter_margin: cx.gutter_dimensions.margin,
}; };
inline_assistant.clone().into_any_element() inline_assistant.clone().into_any_element()
} }
@ -3465,8 +3465,7 @@ impl Render for InlineAssistant {
.on_action(cx.listener(Self::move_down)) .on_action(cx.listener(Self::move_down))
.child( .child(
h_flex() h_flex()
.justify_center() .w(measurements.gutter_width + measurements.gutter_margin)
.w(measurements.gutter_width)
.children(if let Some(error) = self.codegen.read(cx).error() { .children(if let Some(error) = self.codegen.read(cx).error() {
let error_message = SharedString::from(error.to_string()); let error_message = SharedString::from(error.to_string());
Some( Some(
@ -3479,12 +3478,7 @@ impl Render for InlineAssistant {
None None
}), }),
) )
.child( .child(h_flex().flex_1().child(self.render_prompt_editor(cx)))
h_flex()
.w_full()
.ml(measurements.anchor_x - measurements.gutter_width)
.child(self.render_prompt_editor(cx)),
)
} }
} }
@ -3653,8 +3647,8 @@ impl InlineAssistant {
// This wouldn't need to exist if we could pass parameters when rendering child views. // This wouldn't need to exist if we could pass parameters when rendering child views.
#[derive(Copy, Clone, Default)] #[derive(Copy, Clone, Default)]
struct BlockMeasurements { struct BlockMeasurements {
anchor_x: Pixels,
gutter_width: Pixels, gutter_width: Pixels,
gutter_margin: Pixels,
} }
struct PendingInlineAssist { struct PendingInlineAssist {