From d1d4c4ad22869996e23e0f3206ccc8caa958aa54 Mon Sep 17 00:00:00 2001
From: lvgx <l@vgx.fr>
Date: Tue, 29 Sep 2020 16:13:57 +0200
Subject: [PATCH] Snap to edges in no rollover multiline scroll mode

---
 src/nnn.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/nnn.c b/src/nnn.c
index f97ad21c..de671f31 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5972,15 +5972,21 @@ nochange:
 			}
 #if NCURSES_MOUSE_VERSION > 1
 			/* Scroll up */
-			if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur >= scroll_lines)) {
-				move_cursor((cur + ndents - scroll_lines) % ndents, 0);
+			if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
+				if(!cfg.rollover && cur < scroll_lines)
+					move_cursor(0,0);
+				else
+					move_cursor((cur + ndents - scroll_lines) % ndents, 0);
 				break;
 			}
 
 			/* Scroll down */
 			if (event.bstate == BUTTON5_PRESSED && ndents
-			    && (cfg.rollover || (cur + scroll_lines < ndents))) {
-				move_cursor((cur + scroll_lines) % ndents, 0);
+			    && (cfg.rollover || (cur != ndents - 1))) {
+				if(!cfg.rollover && cur >= ndents - scroll_lines)
+					move_cursor(ndents-1, 0);
+				else
+					move_cursor((cur + scroll_lines) % ndents, 0);
 				break;
 			}
 #endif
-- 
2.51.0