on master help sign in
scroll: Fix the clamping
bd4552cBlaž Hrastnik
helix-term/src/commands.rs+2−2
@@ -475,8 +475,8 @@ fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
475 // clamp into viewport
475 // clamp into viewport
476 let line = cursor
476 let line = cursor
477 .row
477 .row
478− .min(view.first_line + scrolloff)
478+ .max(view.first_line + scrolloff)
479− .max(last_line.saturating_sub(scrolloff));
479+ .min(last_line.saturating_sub(scrolloff));
480
480
481 let text = doc.text().slice(..);
481 let text = doc.text().slice(..);
482 let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end
482 let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end