about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/core/actions.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 89c5124b..4e76df65 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -998,12 +998,15 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
     def scroll_preview(self, lines, narg=None):
         """:scroll_preview <lines>
 
-Scroll the file preview by <lines> lines."""
+        Scroll the file preview by <lines> lines.
+        """
         preview_column = self.ui.browser.columns[-1]
         if preview_column.target and preview_column.target.is_file:
             if narg is not None:
                 lines = narg
-            preview_column.scrollbit = max(0, preview_column.scrollbit + lines)
+            target_scroll = preview_column.scrollbit + lines
+            max_scroll = len(preview_column.lines) - preview_column.hei
+            preview_column.scrollbit = max(0, min(target_scroll, max_scroll))
             preview_column.request_redraw()
 
     # --------------------------