Fix scrolloff at view bottom (#6142)

Fixes a regression introduced in #5420 where a scrolloff of `x - 1`
was used instead if `x` at the bottom of the screen. This was
especially problematic if the scrolloff was set to `0` in that case
the scrolloff behaved as tough set to `-1` and the cursor disappeared
from the view if scrolled to the botoom.
pull/6180/head
Pascal Kuthe 2 years ago committed by GitHub
parent 2d5577dbe6
commit 5c716af7a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -242,7 +242,7 @@ impl View {
at_top = true; at_top = true;
true true
} }
Some((visual_pos, _)) if visual_pos.row >= vertical_viewport_end - scrolloff => { Some((visual_pos, _)) if visual_pos.row + scrolloff + 1 >= vertical_viewport_end => {
if CENTERING && visual_pos.row >= vertical_viewport_end { if CENTERING && visual_pos.row >= vertical_viewport_end {
// cursor out of view // cursor out of view
return None; return None;
@ -257,7 +257,7 @@ impl View {
let v_off = if at_top { let v_off = if at_top {
scrolloff as isize scrolloff as isize
} else { } else {
viewport.height as isize - scrolloff as isize viewport.height as isize - scrolloff as isize - 1
}; };
(offset.anchor, offset.vertical_offset) = (offset.anchor, offset.vertical_offset) =
char_idx_at_visual_offset(doc_text, cursor, -v_off, 0, &text_fmt, &annotations); char_idx_at_visual_offset(doc_text, cursor, -v_off, 0, &text_fmt, &annotations);

Loading…
Cancel
Save