@@ -1470,7 +1470,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
1470 let cursor = range.cursor(text);
1470 let cursor = range.cursor(text);
1471 let height = view.inner_height();
1471 let height = view.inner_height();
1473− let scrolloff = config.scrolloff.min(height / 2);
1473+ let scrolloff = config.scrolloff.min(height.saturating_sub(1) as usize / 2);
1474 let offset = match direction {
1474 let offset = match direction {
1475 Forward => offset as isize,
1475 Forward => offset as isize,
1476 Backward => -(offset as isize),
1476 Backward => -(offset as isize),
@@ -1510,7 +1510,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
1510 head = char_idx_at_visual_offset(
1510 head = char_idx_at_visual_offset(
1511 doc_text,
1511 doc_text,
1512 view.offset.anchor,
1512 view.offset.anchor,
1513− (view.offset.vertical_offset + height - scrolloff) as isize,
1513+ (view.offset.vertical_offset + height - scrolloff - 1) as isize,
1515 &text_fmt,
1515 &text_fmt,
1516 &annotations,
1516 &annotations,