From e1791b7dd0ff1948d3d302674fda2f659974c0b3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 24 Apr 2024 14:33:57 +0200 Subject: [PATCH] Autoscroll containing element when editor has a pending selection (#10931) Release Notes: - N/A --- crates/editor/src/element.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 49917d7ade..b886c5db1f 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3501,10 +3501,11 @@ impl Element for EditorElement { let content_origin = text_hitbox.origin + point(gutter_dimensions.margin, Pixels::ZERO); - let mut autoscroll_requested = false; + let mut autoscroll_containing_element = false; let mut autoscroll_horizontally = false; self.editor.update(cx, |editor, cx| { - autoscroll_requested = editor.autoscroll_requested(); + autoscroll_containing_element = + editor.autoscroll_requested() || editor.has_pending_selection(); autoscroll_horizontally = editor.autoscroll_vertically(bounds, line_height, cx); snapshot = editor.snapshot(cx); }); @@ -3683,7 +3684,7 @@ impl Element for EditorElement { scroll_pixel_position, line_height, em_width, - autoscroll_requested, + autoscroll_containing_element, cx, );