From d0530fb83921acc92cd51fd6fa3a8d4846ad5aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 22 Mar 2021 18:06:52 +0900 Subject: [PATCH] Fix a scrolling crash where it would jump past the end of the buffer. --- helix-core/src/auto_pairs.rs | 1 + helix-term/src/commands.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/helix-core/src/auto_pairs.rs b/helix-core/src/auto_pairs.rs index e6b8f6675..aa668f293 100644 --- a/helix-core/src/auto_pairs.rs +++ b/helix-core/src/auto_pairs.rs @@ -54,6 +54,7 @@ fn next_char(doc: &Rope, pos: usize) -> Option { } Some(doc.char(pos)) } +// TODO: selections should be extended if range, moved if point. // TODO: if not cursor but selection, wrap on both sides of selection (surround) fn handle_open( diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3f0e32a0f..fd95bca42 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -433,7 +433,7 @@ fn scroll(view: &mut View, offset: usize, direction: Direction) { // clamp into viewport let line = (view.first_line + cursor_off).clamp( view.first_line + scrolloff, - view.first_line + view.last_line().saturating_sub(scrolloff), + view.last_line().saturating_sub(scrolloff), ); let pos = pos_at_coords(text, Position::new(line, cursor.col)); // this func will properly truncate to line end