From f6f41510d25f78984332fb812745220036d4ee36 Mon Sep 17 00:00:00 2001 From: Kay Simmons Date: Wed, 7 Dec 2022 17:25:48 -0800 Subject: [PATCH] fix failing tests from incorrect follow behavior --- crates/editor/src/items.rs | 3 ++- crates/editor/src/scroll.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 4779fe73b8..73008ca720 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -88,7 +88,7 @@ impl FollowableItem for Editor { } if let Some(anchor) = state.scroll_top_anchor { - editor.set_scroll_anchor( + editor.set_scroll_anchor_internal( ScrollAnchor { top_anchor: Anchor { buffer_id: Some(state.buffer_id as usize), @@ -98,6 +98,7 @@ impl FollowableItem for Editor { }, offset: vec2f(state.scroll_x, state.scroll_y), }, + false, cx, ); } diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index 78bc3685c1..5cb58e21e9 100644 --- a/crates/editor/src/scroll.rs +++ b/crates/editor/src/scroll.rs @@ -284,8 +284,17 @@ impl Editor { } pub fn set_scroll_anchor(&mut self, scroll_anchor: ScrollAnchor, cx: &mut ViewContext) { + self.set_scroll_anchor_internal(scroll_anchor, true, cx); + } + + pub(crate) fn set_scroll_anchor_internal( + &mut self, + scroll_anchor: ScrollAnchor, + local: bool, + cx: &mut ViewContext, + ) { hide_hover(self, cx); - self.scroll_manager.set_anchor(scroll_anchor, true, cx); + self.scroll_manager.set_anchor(scroll_anchor, local, cx); } pub fn scroll_screen(&mut self, amount: &ScrollAmount, cx: &mut ViewContext) {