From e08484840b19bae7d28dfaeac6025d7f649e1cb5 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Sun, 12 Jan 2025 22:33:24 -0700 Subject: [PATCH] Clarify logic for `Autoscroll::newest()` and `Autoscroll::fit()` (#23048) Release Notes: - N/A --- crates/editor/src/scroll/autoscroll.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rs index 8ae5dea7205c2a..3f64831909f4ee 100644 --- a/crates/editor/src/scroll/autoscroll.rs +++ b/crates/editor/src/scroll/autoscroll.rs @@ -128,9 +128,9 @@ impl Editor { .next_row() .as_f32(); - // If the selections can't all fit on screen, scroll to the newest. + let selections_fit = target_bottom - target_top <= visible_lines; if autoscroll == Autoscroll::newest() - || autoscroll == Autoscroll::fit() && target_bottom - target_top > visible_lines + || (autoscroll == Autoscroll::fit() && !selections_fit) { let newest_selection_top = selections .iter()