fix failing tests from incorrect follow behavior

This commit is contained in:
Kay Simmons 2022-12-07 17:25:48 -08:00
parent cffb064c16
commit f6f41510d2
2 changed files with 12 additions and 2 deletions

View file

@ -88,7 +88,7 @@ impl FollowableItem for Editor {
} }
if let Some(anchor) = state.scroll_top_anchor { if let Some(anchor) = state.scroll_top_anchor {
editor.set_scroll_anchor( editor.set_scroll_anchor_internal(
ScrollAnchor { ScrollAnchor {
top_anchor: Anchor { top_anchor: Anchor {
buffer_id: Some(state.buffer_id as usize), buffer_id: Some(state.buffer_id as usize),
@ -98,6 +98,7 @@ impl FollowableItem for Editor {
}, },
offset: vec2f(state.scroll_x, state.scroll_y), offset: vec2f(state.scroll_x, state.scroll_y),
}, },
false,
cx, cx,
); );
} }

View file

@ -284,8 +284,17 @@ impl Editor {
} }
pub fn set_scroll_anchor(&mut self, scroll_anchor: ScrollAnchor, cx: &mut ViewContext<Self>) { pub fn set_scroll_anchor(&mut self, scroll_anchor: ScrollAnchor, cx: &mut ViewContext<Self>) {
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<Self>,
) {
hide_hover(self, cx); 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<Self>) { pub fn scroll_screen(&mut self, amount: &ScrollAmount, cx: &mut ViewContext<Self>) {