on master help sign in
make scrolloff calculation consistent

While scrolling (with the `scroll`) command scrolloff was calculated slightly differently than in `ensure_cursor_in_view` which could cause the cursor to get stuck while scrolling

commit15e751b9a291b8732468235af95142bfbd0c9be2 authorPascal Kuthe <pascal.kuthe@semimod.de> dateWed 22 Mar 2023, 16:45 (4 years ago) parentd6c8e0c
1 file changed+2−2
helix-term/src/commands.rs+2−2
helix-term/src/commands.rs+2−2
@@ -1470,7 +1470,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
14701470 let cursor = range.cursor(text);
14711471 let height = view.inner_height();
14721472
1473− let scrolloff = config.scrolloff.min(height / 2);
1473+ let scrolloff = config.scrolloff.min(height.saturating_sub(1) as usize / 2);
14741474 let offset = match direction {
14751475 Forward => offset as isize,
14761476 Backward => -(offset as isize),
@@ -1510,7 +1510,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
15101510 head = char_idx_at_visual_offset(
15111511 doc_text,
15121512 view.offset.anchor,
1513− (view.offset.vertical_offset + height - scrolloff) as isize,
1513+ (view.offset.vertical_offset + height - scrolloff - 1) as isize,
15141514 0,
15151515 &text_fmt,
15161516 &annotations,