Fix clicking in to agent message editor and tighten up vertical spacing (#32765)
* Adds `min_lines` to `EditorMode::AutoHeight` and use `min_lines: 4` in agent message editor. This makes it so that clicks in the blank space below the first line of the editor also focus it, instead of needing to click the very first line. * Removes the div wrapping the editor, as it was only there to set `min_h_16()`. This also tightens up the min space given to the editor - before it was not evenly dividing the number of lines. * Further tightens up vertical spacing by using `gap_1` instead of `gap_4` between editor and controls below At 4 line min height (after on the left, before on the right):  At 5 lines, one more than min height (after on the left, before on the right):  Release Notes: - Agent: Fixed clicking to focus the message editor to also work for clicks below the last line.
This commit is contained in:
parent
a994666888
commit
681c88d4e7
10 changed files with 73 additions and 46 deletions
|
@ -7681,7 +7681,10 @@ impl Element for EditorElement {
|
|||
window.request_layout(style, None, cx)
|
||||
}
|
||||
}
|
||||
EditorMode::AutoHeight { max_lines } => {
|
||||
EditorMode::AutoHeight {
|
||||
min_lines,
|
||||
max_lines,
|
||||
} => {
|
||||
let editor_handle = cx.entity().clone();
|
||||
let max_line_number_width =
|
||||
self.max_line_number_width(&editor.snapshot(window, cx), window, cx);
|
||||
|
@ -7692,6 +7695,7 @@ impl Element for EditorElement {
|
|||
.update(cx, |editor, cx| {
|
||||
compute_auto_height_layout(
|
||||
editor,
|
||||
min_lines,
|
||||
max_lines,
|
||||
max_line_number_width,
|
||||
known_dimensions,
|
||||
|
@ -9864,6 +9868,7 @@ pub fn register_action<T: Action>(
|
|||
|
||||
fn compute_auto_height_layout(
|
||||
editor: &mut Editor,
|
||||
min_lines: usize,
|
||||
max_lines: usize,
|
||||
max_line_number_width: Pixels,
|
||||
known_dimensions: Size<Option<Pixels>>,
|
||||
|
@ -9911,7 +9916,7 @@ fn compute_auto_height_layout(
|
|||
|
||||
let scroll_height = (snapshot.max_point().row().next_row().0 as f32) * line_height;
|
||||
let height = scroll_height
|
||||
.max(line_height)
|
||||
.max(line_height * min_lines as f32)
|
||||
.min(line_height * max_lines as f32);
|
||||
|
||||
Some(size(width, height))
|
||||
|
@ -10214,7 +10219,10 @@ mod tests {
|
|||
|
||||
for editor_mode_without_invisibles in [
|
||||
EditorMode::SingleLine { auto_width: false },
|
||||
EditorMode::AutoHeight { max_lines: 100 },
|
||||
EditorMode::AutoHeight {
|
||||
min_lines: 1,
|
||||
max_lines: 100,
|
||||
},
|
||||
] {
|
||||
for show_line_numbers in [true, false] {
|
||||
let invisibles = collect_invisibles_from_new_editor(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue