aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorPascal Kuthe2023-03-22 15:45:22 +0000
committerBlaž Hrastnik2023-03-27 00:54:40 +0000
commit15e751b9a291b8732468235af95142bfbd0c9be2 (patch)
tree440ed611b28b32100124c8dcfd0e9ae6ff0de7b7 /helix-term
parentd6c8e0c946d768abdb2d688cb7cd67683ac51240 (diff)
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
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d53df831..4a7b7883 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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),
@@ -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,