agent: Make the message editor expandable (#28420)

This PR allows expanding the message editor textarea to fit almost the
total height of the Agent Panel. Stylistically, I'm also changing the
font family we use in the textarea to use the buffer font; want to
experiment with this for a bit.

Release Notes:

- agent: The Agent Panel textarea can now be expanded to fill almost the
total height of the panel.

---------

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
This commit is contained in:
Danilo Leal 2025-04-10 21:53:52 -03:00 committed by GitHub
parent 2440faf4b2
commit 71c2a11bd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 142 additions and 31 deletions

View file

@ -396,14 +396,26 @@ pub enum SelectMode {
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum EditorMode {
SingleLine { auto_width: bool },
AutoHeight { max_lines: usize },
Full,
SingleLine {
auto_width: bool,
},
AutoHeight {
max_lines: usize,
},
Full {
/// When set to `true`, the editor will scale its UI elements with the buffer font size.
scale_ui_elements_with_buffer_font_size: bool,
/// When set to `true`, the editor will render a background for the active line.
show_active_line_background: bool,
},
}
impl EditorMode {
pub fn full() -> Self {
Self::Full
Self::Full {
scale_ui_elements_with_buffer_font_size: true,
show_active_line_background: true,
}
}
pub fn is_full(&self) -> bool {

View file

@ -4176,7 +4176,11 @@ impl EditorElement {
self.style.background,
));
if let EditorMode::Full { .. } = layout.mode {
if let EditorMode::Full {
show_active_line_background,
..
} = layout.mode
{
let mut active_rows = layout.active_rows.iter().peekable();
while let Some((start_row, contains_non_empty_selection)) = active_rows.next() {
let mut end_row = start_row.0;
@ -4191,7 +4195,7 @@ impl EditorElement {
end_row += 1;
}
if !contains_non_empty_selection.selection {
if show_active_line_background && !contains_non_empty_selection.selection {
let highlight_h_range =
match layout.position_map.snapshot.current_line_highlight {
CurrentLineHighlight::Gutter => Some(Range {
@ -6414,7 +6418,13 @@ impl EditorElement {
/// This allows UI elements to scale based on the `buffer_font_size`.
fn rem_size(&self, cx: &mut App) -> Option<Pixels> {
match self.editor.read(cx).mode {
EditorMode::Full { .. } => {
EditorMode::Full {
scale_ui_elements_with_buffer_font_size,
..
} => {
if !scale_ui_elements_with_buffer_font_size {
return None;
}
let buffer_font_size = self.style.text.font_size;
match buffer_font_size {
AbsoluteLength::Pixels(pixels) => {