Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Clarify logic for `Autoscroll::newest()` and `Autoscroll::fit()` (#23048)

Michael Sloane08484840b19
diff --git a/crates/editor/src/scroll/autoscroll.rs b/crates/editor/src/scroll/autoscroll.rs
index 8ae5dea7205..3f64831909f 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()