on master help sign in
Fix goto/view center mismatch (#4135)
530f9e3Brandon Dong
helix-view/src/lib.rs+3−3
@@ -53,12 +53,12 @@ pub fn align_view(doc: &Document, view: &mut View, align: Align) {
53 .cursor(doc.text().slice(..));
53 .cursor(doc.text().slice(..));
54 let line = doc.text().char_to_line(pos);
54 let line = doc.text().char_to_line(pos);
55
55
56− let height = view.inner_area().height as usize;
56+ let last_line_height = view.inner_area().height.saturating_sub(1) as usize;
57
57
58 let relative = match align {
58 let relative = match align {
59− Align::Center => height / 2,
59+ Align::Center => last_line_height / 2,
60 Align::Top => 0,
60 Align::Top => 0,
61− Align::Bottom => height,
61+ Align::Bottom => last_line_height,
62 };
62 };
63
63
64 view.offset.row = line.saturating_sub(relative);
64 view.offset.row = line.saturating_sub(relative);