diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index aa41624029..b3d74d03a7 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 f3f00ee016..1ce59dd93f 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); } } }