on master help sign in
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.

commit5c716af7a2c2fff36080d51be3cb9fa30aa36bc7 authorPascal Kuthe <pascal.kuthe@semimod.de> dateFri 3 Mar 2023, 17:05 (4 years ago) parent2d5577d
1 file changed+2−2
helix-view/src/view.rs+2−2
helix-view/src/view.rs+2−2
@@ -242,7 +242,7 @@ impl View {
242242 at_top = true;
243243 true
244244 }
245− Some((visual_pos, _)) if visual_pos.row >= vertical_viewport_end - scrolloff => {
245+ Some((visual_pos, _)) if visual_pos.row + scrolloff + 1 >= vertical_viewport_end => {
246246 if CENTERING && visual_pos.row >= vertical_viewport_end {
247247 // cursor out of view
248248 return None;
@@ -257,7 +257,7 @@ impl View {
257257 let v_off = if at_top {
258258 scrolloff as isize
259259 } else {
260− viewport.height as isize - scrolloff as isize
260+ viewport.height as isize - scrolloff as isize - 1
261261 };
262262 (offset.anchor, offset.vertical_offset) =
263263 char_idx_at_visual_offset(doc_text, cursor, -v_off, 0, &text_fmt, &annotations);