diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index fdb443e987..6f247d2768 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -12120,12 +12120,18 @@ impl Editor { &mut self, excerpt: ExcerptId, direction: ExpandExcerptDirection, + window: &mut Window, cx: &mut Context, ) { + let current_scroll_position = self.scroll_position(cx); let lines = EditorSettings::get_global(cx).expand_excerpt_lines; self.buffer.update(cx, |buffer, cx| { buffer.expand_excerpts([excerpt], lines, direction, cx) - }) + }); + if direction == ExpandExcerptDirection::Down { + let new_scroll_position = current_scroll_position + gpui::Point::new(0.0, lines as f32); + self.set_scroll_position(new_scroll_position, window, cx); + } } pub fn go_to_singleton_buffer_point( diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 5001dcebbd..f122aaa9d8 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2263,9 +2263,9 @@ impl EditorElement { .selected_icon_color(Color::Custom(cx.theme().colors().editor_foreground)) .icon_size(IconSize::Custom(rems(editor_font_size / window.rem_size()))) .width(width.into()) - .on_click(move |_, _, cx| { + .on_click(move |_, window, cx| { editor.update(cx, |editor, cx| { - editor.expand_excerpt(excerpt_id, direction, cx); + editor.expand_excerpt(excerpt_id, direction, window, cx); }); }) .tooltip(Tooltip::for_action_title(