diff options
author | GermainZ <germanosz@gmail.com> | 2018-10-14 17:23:11 +0200 |
---|---|---|
committer | GermainZ <germanosz@gmail.com> | 2018-10-14 18:41:28 +0200 |
commit | b0016cb93da5b65277403dd99c06d7f0a09dfbcc (patch) | |
tree | fb8b022ccd5a62a90d29fbef9d287554fec57bd3 | |
parent | 21c2f54a38e4f66060cf9eb95beaaef37cbca580 (diff) | |
download | ranger-b0016cb93da5b65277403dd99c06d7f0a09dfbcc.tar.gz |
Do not allow scrolling beyond end of file preview
-rw-r--r-- | ranger/core/actions.py | 7 |
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() # -------------------------- |