From 0e920ad5e97aa1c4638a9027a3ea2f8e7f67051d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Sat, 19 Mar 2022 10:50:23 +0100 Subject: [PATCH] Unset follower's scroll anchor when editor is scrolled all the way up --- crates/editor/src/editor.rs | 4 ++-- crates/editor/src/items.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index aa4162402943f6ad08c8cba0d4425d279e4a9f31..b3d74d03a7fb66821208fffdbf4d7e140590489e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1037,9 +1037,9 @@ impl Editor { cx.notify(); } - fn set_scroll_top_anchor(&mut self, anchor: Anchor, cx: &mut ViewContext) { + fn set_scroll_top_anchor(&mut self, anchor: Option, cx: &mut ViewContext) { self.scroll_position = Vector2F::zero(); - self.scroll_top_anchor = Some(anchor); + self.scroll_top_anchor = anchor; cx.emit(Event::ScrollPositionChanged); cx.notify(); } diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index f3f00ee01605a6d26acd2e792d687bd6046cabda..1ce59dd93fe8df9ad977883655b08538aef31598 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -95,7 +95,9 @@ impl FollowableItem for Editor { let (excerpt_id, _, _) = buffer.as_singleton().unwrap(); buffer.anchor_in_excerpt(excerpt_id.clone(), anchor) }; - self.set_scroll_top_anchor(anchor, cx); + self.set_scroll_top_anchor(Some(anchor), cx); + } else { + self.set_scroll_top_anchor(None, cx); } } }