Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-view/src/lib.rs')
| -rw-r--r-- | helix-view/src/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-view/src/lib.rs b/helix-view/src/lib.rs index 5628c830..d54b49ef 100644 --- a/helix-view/src/lib.rs +++ b/helix-view/src/lib.rs @@ -47,11 +47,12 @@ pub enum Align { Bottom, } -pub fn align_view(doc: &Document, view: &mut View, align: Align) { +pub fn align_view(doc: &mut Document, view: &View, align: Align) { let doc_text = doc.text().slice(..); let cursor = doc.selection(view.id).primary().cursor(doc_text); let viewport = view.inner_area(doc); let last_line_height = viewport.height.saturating_sub(1); + let mut view_offset = doc.view_offset(view.id); let relative = match align { Align::Center => last_line_height / 2, @@ -60,15 +61,15 @@ pub fn align_view(doc: &Document, view: &mut View, align: Align) { }; let text_fmt = doc.text_format(viewport.width, None); - let annotations = view.text_annotations(doc, None); - (view.offset.anchor, view.offset.vertical_offset) = char_idx_at_visual_offset( + (view_offset.anchor, view_offset.vertical_offset) = char_idx_at_visual_offset( doc_text, cursor, -(relative as isize), 0, &text_fmt, - &annotations, + &view.text_annotations(doc, None), ); + doc.set_view_offset(view.id, view_offset); } pub use document::Document; |