Skip to content

Commit

Permalink
make scrolloff calculation consistent
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pascalkuthe authored and archseer committed Mar 27, 2023
1 parent d6c8e0c commit 15e751b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
let cursor = range.cursor(text);
let height = view.inner_height();

let scrolloff = config.scrolloff.min(height / 2);
let scrolloff = config.scrolloff.min(height.saturating_sub(1) as usize / 2);
let offset = match direction {
Forward => offset as isize,
Backward => -(offset as isize),
Expand Down Expand Up @@ -1510,7 +1510,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
head = char_idx_at_visual_offset(
doc_text,
view.offset.anchor,
(view.offset.vertical_offset + height - scrolloff) as isize,
(view.offset.vertical_offset + height - scrolloff - 1) as isize,
0,
&text_fmt,
&annotations,
Expand Down

0 comments on commit 15e751b

Please sign in to comment.