Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Preserve expand excerpt down button position (#27058)
Smit Barmase2230f3b09d93
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex fdb443e987f..6f247d27687 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<Self>,) {+ 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.rsindex 5001dcebbd9..f122aaa9d86 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(